dotfiles/.doom.d/config.org

830 lines
26 KiB
Org Mode
Raw Normal View History

2020-01-16 19:03:06 +01:00
#+TITLE: My Doom Emacs config
#+AUTHOR: Iñigo Ortega
#+EMAIL: inigoortega@tutanota.com
#+LANGUAGE: en
#+STARTUP: inlineimages
#+PROPERTY: header-args :tangle yes :cache yes :results silent :padline no :config literate
#+OPTIONS: toc:nil
#+EXPORT_FILE_NAME: README
* Lexical binding
#+BEGIN_SRC emacs-lisp
;; -*- lexical-binding: t -*-
#+END_SRC
* User configs
These are used for a number of things, particularly for GPG configuration,
some email clients, file templates and snippets.
#+BEGIN_SRC elisp
(setq user-full-name "inigoortega"
user-mail-address "inigoortega@tutanota.com")
#+END_SRC
* Style
** Fonts
Doom exposes five (optional) variables for controlling fonts in Doom. Here
are the three important ones:
+ `doom-font'
+ `doom-variable-pitch-font'
+ `doom-big-font' -- used for `doom-big-font-mode'
They all accept either a font-spec, font string ("Input Mono-12"), or xlfd
font string. You generally only need these two:
test
#+BEGIN_SRC emacs-lisp
2020-03-08 13:38:31 +01:00
(setq doom-font (font-spec :family "monospace" :width 'normal :size 17)
2020-01-16 19:03:06 +01:00
doom-variable-pitch-font (font-spec :family "monospace"))
#+END_SRC
** Theme
There are two ways to load a theme. Both assume the theme is installed and
available. You can either set `doom-theme' or manually load a theme with the
`load-theme' function. These are the defaults.
#+BEGIN_SRC emacs-lisp
(setq doom-theme 'doom-gruvbox)
#+END_SRC
** Line numbers
If you want to change the style of line numbers, change this to `relative' or
`nil' to disable it:
#+BEGIN_SRC emacs-lisp
(setq display-line-numbers-type 'relative)
#+END_SRC
* Org
If you intend to use org, it is recommended you change this!
#+BEGIN_SRC emacs-lisp
(setq org-directory "~/org/")
#+END_SRC
* Custom variables
#+BEGIN_SRC emacs-lisp
(setq sh-symbols
2020-02-21 11:52:49 +01:00
'(sed tail printf echo pidof top dmenu rofi killall sed awk tee basename
ln mkdir rm ssh sleep source ps bash python perl Rscript wget
bunzip2 bzip2 zip unzip gzip gunzip find ls cat egrep grep mv cp
chmod tar stty export spark-shell spark-submit hadoop pyspark aws
2020-04-21 00:01:51 +02:00
dash xdotool xprop 7z p7z zsh fish expr command disown pv alias
2020-01-16 19:03:06 +01:00
))
2020-01-20 15:53:32 +01:00
(setq prelude-symbols
'(not otherwise maybe either fst snd curry uncurry compare min max succ
2020-03-29 16:54:56 +02:00
pred toEnum fromEnum enumFrom enumFromThen enumFromTo enumFromThenTo
minBound maxBound abs negate signum fromInteger show showsPrec showList
toInteger toRational quot rem div mod quotRem divMod toInteger recip
fromRational pi exp log sqrt logBase sin cos tan asin acos atan sinh cosh
tanh asinh acosh atanh map properFraction truncate round ceiling floor
floatRadix floatDigits floatRange decodeFloat encodeFloat exponent
significand scaleFloat isNaN isInfinite isDenormalized isNegativeZero
isIEEE atan2 subtract odd even gcd lcm fromIntegral realToFrac mempty
mappend mconcat fmap pure return fail mapM_ sequence foldMap foldr foldl
foldr1 foldl1 elem minimum sum product traverse sequenceA mapM id const
flip until asTypeOf error errorWithoutStackTrace undefined seq filter head
last tail init null length reverse and or any all concat concatMap scanl
scanr scanr1 iterate repeat replicate cycle take drop dropWhile takeWhile
splitAt span break notElem lookup zip zip3 zipWith zipWith3 unzip unzip3
lines words unlines unwords shows showChar showString showParen readsPrec
readList reads readParen read lex putChar putStr putStrLn print getChar
getLine getContents interact readFile writeFile appendFile readIO readLn
ioError userError))
2020-01-20 15:53:32 +01:00
2020-01-16 19:03:06 +01:00
(setq path-to-ctags "/usr/bin/ctags")
2020-01-20 15:53:32 +01:00
(setq i-keys (mapcar
2020-05-06 18:47:54 +02:00
(lambda (number) (setq command (format "%c" number)))
2020-01-20 15:53:32 +01:00
(number-sequence 35 91)))
(nconc i-keys (mapcar
2020-05-06 18:47:54 +02:00
(lambda (number) (setq command (format "%c" number)))
2020-03-29 16:54:56 +02:00
(number-sequence 93 250)))
2020-05-06 12:29:35 +02:00
(setq my-unignored-buffers '("*ielm*" "*scratch*" "*ansi-term*" "*term*"))
2020-05-06 18:47:54 +02:00
(setq insert-on-mode #s(hash-table size 30 data (shell-mode insert term-mode term-send-raw-string prog-mode insert!)))
(setq compression-extensions '("7z" "7zip" "zip" "zstd" "tar\..*"))
2020-01-16 19:03:06 +01:00
#+END_SRC
* Custom functions
#+BEGIN_SRC emacs-lisp
(defun eval-string (string)
"Evals all the commands inside the string"
(eval (car (read-from-string (format "(progn %s)" string)))))
;;; Shell script highlighting
2020-01-20 15:53:32 +01:00
(defun highlight-words-on-mode (mode symbols &optional face)
2020-01-16 19:03:06 +01:00
"Makes given symbols be highlighted on given mode"
(setq strings (mapcar 'symbol-name symbols))
(setq formatted-words
(concat "\\\\<\\\\(" (mapconcat 'identity
strings "\\\\|") "\\\\)\\\\>"))
2020-01-20 15:53:32 +01:00
(if face
(eval-string (format "(font-lock-add-keywords '%s '((\"%s\" .
%s)))" mode formatted-words face))
(eval-string (format "(font-lock-add-keywords '%s '((\"%s\" .
%s)))" mode formatted-words font-lock-builtin-face))
)
2020-01-16 19:03:06 +01:00
;; highlight options
(font-lock-add-keywords
mode
'(("\\<-[-a-zA-Z0-9]+\\>"
. font-lock-constant-face)))
(font-lock-add-keywords
2020-01-20 15:53:32 +01:00
mode
2020-01-16 19:03:06 +01:00
`((,(concat "[ \t]+"
(regexp-opt
'("!" "!=" "==" "=~") 'paren) "[ \t]+")
. font-lock-constant-face)))
)
(defun create-tags (dir-name)
"Create tags file."
(interactive "DDirectory: ")
(shell-command
(format "%s -f TAGS -e -R %s" path-to-ctags (directory-file-name dir-name)))
)
#+END_SRC
2020-04-30 02:35:14 +02:00
Xah Lee, read .bashrc:
#+BEGIN_SRC emacs-lisp
;; from xah-lee http://ergoemacs.org/emacs/elisp_read_file_content.html
(defun re-n-matches ()
(1- (/ (length (match-data)) 2)))
(defun get-string-from-file (filePath)
"Return filePath's file content."
(with-temp-buffer
(insert-file-contents filePath)
(buffer-string)))
(defun match-strings-all (&optional string)
"Return the list of all expressions matched in last search.
STRING is optionally what was given to `string-match'."
(loop for i from 0 to (re-n-matches)
collect (match-string-no-properties i string)))
(defun re-find-all (regexp string &optional groups yes-props)
"like python's re.find_all"
(let (
;;(groups (or groups (list (regexp-count-capture-groups regexp))))
(match-string-fun (if (not yes-props) 'match-string 'match-string-no-properties))
(start 0)
(matches nil )
)
(while (setq start (and (string-match regexp string start) (match-end 0)))
(setq matches (cons (cdr (match-strings-all string)) matches))
)
(setq matches (reverse matches))
(if (not (cdar matches))
(mapcar 'car matches)
matches
)
)
)
(defun apply-eshell-alias (alias &rest definition)
"basically taken from eshell/alias function"
(if (not definition)
(setq eshell-command-aliases-list
(delq (assoc alias eshell-command-aliases-list)
eshell-command-aliases-list))
(and (stringp definition)
(set-text-properties 0 (length definition) nil definition))
(let ((def (assoc alias eshell-command-aliases-list))
(alias-def (list alias
(eshell-flatten-and-stringify definition))))
(if def
(setq eshell-command-aliases-list
(delq def eshell-command-aliases-list)))
(setq eshell-command-aliases-list
(cons alias-def eshell-command-aliases-list))))
)
(defun eshell-load-bashrc-aliases ()
(interactive)
(mapc (lambda (alias-def) (apply 'eshell/alias alias-def))
(re-find-all "^alias \\([^=]+\\)='?\\(.+?\\)'?$"
(get-string-from-file (concat (getenv "HOME") "/" ".alias"))
)
)
)
#+END_SRC
2020-05-06 12:29:35 +02:00
#+BEGIN_SRC emacs-lisp
(defun make-buffer-uninteresting ()
"rename the current buffer to begin with a space"
(interactive)
(unless (string-match-p "^ " (buffer-name))
(rename-buffer (concat " " (buffer-name)))))
(defun make-buffer-interesting ()
"rename the current buffer to begin with a space"
(interactive)
(if (string-match-p "^ " (buffer-name))
(rename-buffer (concat " " (buffer-name)))))
#+END_SRC
2020-06-17 22:43:39 +02:00
Ansi-term for TRAMP:
#+BEGIN_SRC emacs-lisp
(defun dfeich/ansi-terminal (&optional path name)
"Opens an ansi terminal at PATH. If no PATH is given, it uses
the value of `default-directory'. PATH may be a tramp remote path.
The ansi-term buffer is named based on `name' "
(interactive)
(unless path (setq path default-directory))
(unless name (setq name "ansi-term"))
(ansi-term "/bin/bash" name)
(let ((path (replace-regexp-in-string "^file:" "" path))
(cd-str
"fn=%s; if test ! -d $fn; then fn=$(dirname $fn); fi; cd $fn;")
(bufname (concat "*" name "*" )))
(if (tramp-tramp-file-p path)
(let ((tstruct (tramp-dissect-file-name path)))
(cond
((equal (tramp-file-name-method tstruct) "ssh")
(process-send-string bufname (format
(concat "ssh -t %s '"
cd-str
"exec bash'; exec bash; clear\n")
(tramp-file-name-host tstruct)
(tramp-file-name-localname tstruct))))
(t (error "not implemented for method %s"
(tramp-file-name-method tstruct)))))
(process-send-string bufname (format (concat cd-str " exec bash;clear\n")
path)))))
#+END_SRC
2020-05-06 18:47:54 +02:00
ii mode:
2020-01-16 19:03:06 +01:00
#+BEGIN_SRC emacs-lisp
2020-05-06 18:47:54 +02:00
(defun ins-mode (str)
(interactive)
(setq f (gethash major-mode insert-on-mode))
(if (eq f nil)
(insert! str)
(funcall f str)
)
)
(defun ii-mode ()
2020-04-28 14:09:26 +02:00
(mapcar
2020-05-06 18:47:54 +02:00
(lambda (key)
2020-04-28 14:09:26 +02:00
(eval-string
(format "(map!
2020-05-06 18:47:54 +02:00
:i \"i %s\" (lambda() (interactive) (ins-mode \"i\") (execute-kbd-macro (kbd \"%s\"))))"
key key))) i-keys)
2020-04-21 00:01:51 +02:00
2020-04-28 14:09:26 +02:00
;; Exceptions
2020-05-06 18:47:54 +02:00
(map! :i "i !" (lambda()
2020-04-28 14:09:26 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "!"))))
(map! :i "i \"" (lambda()
2020-04-21 00:01:51 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd (format "%c" 34)))))
(map! :i "i SPC" (lambda()
2020-04-28 14:09:26 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i ")
))
(map! :i "i ESC" (lambda()
2020-04-28 14:09:26 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
;; (execute-kbd-macro (kbd "ESC"))))
(evil-normal-state)))
(map! :i "i C-g" (lambda()
(interactive)
(ins-mode "i")
))
2020-05-06 18:47:54 +02:00
(map! :i "i RET" (lambda()
2020-04-28 14:09:26 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
2020-04-28 14:09:26 +02:00
(execute-kbd-macro (kbd "RET"))))
2020-05-06 18:47:54 +02:00
(map! :i "i \\" (lambda()
2020-04-21 00:01:51 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "\\"))))
(map! :i "i DEL" (lambda()
2020-04-21 00:01:51 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ignore)))
(map! :i "i TAB" (lambda()
2020-04-21 00:01:51 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
2020-04-28 14:09:26 +02:00
(execute-kbd-macro (kbd "TAB"))))
2020-05-06 18:47:54 +02:00
(map! :i "i C-n" (lambda()
2020-04-21 00:01:51 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "C-n"))))
;; (evil-complete-next)))
2020-04-21 00:01:51 +02:00
2020-04-28 14:09:26 +02:00
;; F keys
2020-05-06 18:47:54 +02:00
(map! :i "i <f1>" (lambda()
2020-04-28 14:09:26 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "<f1>"))))
(map! :i "i <f2>" (lambda()
2020-04-28 14:09:26 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "<f2>"))))
(map! :i "i <f3>" (lambda()
2020-04-28 14:09:26 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "<f3>"))))
(map! :i "i <f4>" (lambda()
2020-04-28 14:09:26 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "<f4>"))))
(map! :i "i <f5>" (lambda()
2020-04-28 14:09:26 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "<f5>"))))
(map! :i "i <f6>" (lambda()
2020-04-28 14:09:26 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "<f6>"))))
(map! :i "i <f7>" (lambda()
2020-04-28 14:09:26 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "<f7>"))))
(map! :i "i <f8>" (lambda()
2020-04-28 14:09:26 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "<f8>"))))
(map! :i "i <f9>" (lambda()
2020-04-28 14:09:26 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "<f9>"))))
(map! :i "i <f10>" (lambda()
2020-04-28 14:09:26 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "<f10>"))))
(map! :i "i <f11>" (lambda()
2020-04-21 00:01:51 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "<f11>"))))
(map! :i "i <f12>" (lambda()
2020-04-28 14:09:26 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "<f12>"))))
2020-04-28 14:09:26 +02:00
;; Other special keys
2020-05-06 18:47:54 +02:00
(map! :i "i <pause>" (lambda()
2020-04-28 14:09:26 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "<pause>"))))
(map! :i "i <Scroll_Lock>" (lambda()
2020-04-28 14:09:26 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "<Scroll_Lock>"))))
(map! :i "i <insert>" (lambda()
2020-04-28 14:09:26 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "<insert>"))))
(map! :i "i <deletechar>" (lambda()
2020-04-28 14:09:26 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "<deletechar>"))))
(map! :i "i <home>" (lambda()
2020-04-21 00:01:51 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "<home>"))))
(map! :i "i <end>" (lambda()
2020-04-21 00:01:51 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "<end>"))))
(map! :i "i <prior>" (lambda()
2020-04-28 14:09:26 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "<prior>"))))
(map! :i "i <next>" (lambda()
2020-04-28 14:09:26 +02:00
(interactive)
2020-05-06 18:47:54 +02:00
(ins-mode "i")
(execute-kbd-macro (kbd "<next>"))))
2020-04-28 14:09:26 +02:00
;; i i
2020-05-06 18:47:54 +02:00
(map! :i "i i" #'evil-normal-state)
2020-04-28 14:09:26 +02:00
)
2020-01-23 15:10:39 +01:00
2020-04-28 14:09:26 +02:00
#+END_SRC
#+BEGIN_SRC emacs-lisp
(defun get-file-type (file &optional deref-symlinks)
"Return the type of FILE, according to the `file' command.
If you give a prefix to this command, and FILE is a symbolic
link, then the type of the file linked to by FILE is returned
instead."
(let (process-file-side-effects)
(with-temp-buffer
(if deref-symlinks
(process-file "file" nil t t "-bL" "--" file)
(process-file "file" nil t t "-b" "--" file))
(when (bolp)
(backward-delete-char 1))
(buffer-string))))
#+END_SRC
2020-05-06 18:47:54 +02:00
* Custom keybindings
Replace with Regiser:
#+BEGIN_SRC emacs-lisp
(map! :n "g r" #'evil-replace-with-register)
(evil-replace-with-register-install)
#+END_SRC
Delete other windows:
#+BEGIN_SRC emacs-lisp
(map! :n "SPC w D" #'delete-other-windows)
#+END_SRC
zsh as ansi-term shell
#+BEGIN_SRC emacs-lisp
(defvar my-term-shell "/bin/zsh")
(setq tramp-shell-prompt-pattern "$ ")
;; (eval-after-load 'tramp '(setenv "SHELL" "/bin/bash"))
(defadvice ansi-term (before force-bash)
(interactive (list my-term-shell)))
(ad-activate 'ansi-term)
#+END_SRC
#+BEGIN_SRC emacs-lisp
(map! :map 'pdf-view-mode-map
:n "f" #'pdf-links-action-perform)
#+END_SRC
#+BEGIN_SRC emacs-lisp
(map! :n "SPC f z" #'counsel-fzf)
#+END_SRC
#+BEGIN_SRC emacs-lisp
(map! :n "SPC b j" #'ivy-switch-buffer)
(map! :n "SPC j j" #'ivy-switch-buffer)
2020-06-17 22:43:39 +02:00
(map! :map 'ranger-mode-map :g "SPC b j" #'ivy-switch-buffer)
(map! :map 'ranger-mode-map :g "SPC j j" #'ivy-switch-buffer)
2020-05-06 18:47:54 +02:00
#+END_SRC
#+BEGIN_SRC emacs-lisp
(map! :n "SPC o c" #'calendar)
2020-06-17 22:43:39 +02:00
(map! :n "SPC o s" #'ansi-term)
(map! :map 'ranger-mode-map :g "SPC o c" #'calendar)
(map! :map 'ranger-mode-map :g "SPC o s"
(lambda() (interactive)
(if (file-remote-p default-directory)
(dfeich/ansi-terminal)
(ansi-term my-term-shell))))
2020-05-06 18:47:54 +02:00
#+END_SRC
Emacs powered window manager keybinding clones:
#+BEGIN_SRC emacs-lisp
(map! :n "SPC j h" (lambda () (interactive) (ansi-term "htop")))
#+END_SRC
Real buffer:
#+BEGIN_SRC emacs-lisp
(defun mark-real-user-buffer()
(interactive)
(setq buf-name (buffer-name))
(switch-to-buffer "*scratch*")
(switch-to-buffer buf-name)
)
(map! :n "SPC b R" (lambda ()
(interactive)
(mark-real-user-buffer)
))
#+END_SRC
** Dired
#+BEGIN_SRC emacs-lisp
(map! :map 'dired-mode-map :n "A" (lambda () (interactive) (find-alternate-file "..")))
2020-06-20 13:00:00 +02:00
(map! :map 'dired-mode-map
:n "w" #'peep-dired
)
(map! :map 'dired-mode-map :n "a"
(lambda ()
(interactive)
(if (equal (get-file-type (dired-get-file-for-visit)) "directory")
(dired-find-alternate-file)
(dired-find-file))
))
(map! :map 'dired-mode-map :n "l"
(lambda ()
(interactive)
(if (equal (get-file-type (dired-get-file-for-visit)) "directory")
(dired-find-alternate-file)
(dired-find-file))
))
(map! :map 'dired-mode-map :n "SPC m o" #'hydra-dired-quick-sort/body)
(map! :map 'dired-mode-map :n "h" (lambda () (interactive) (find-alternate-file "..")))
#+END_SRC
2020-05-06 18:47:54 +02:00
** 'ii' in INSERT mode to escape to NORMAL mode:
2020-04-28 14:09:26 +02:00
#+BEGIN_SRC emacs-lisp
2020-05-06 18:47:54 +02:00
(ii-mode)
2020-04-28 14:09:26 +02:00
;; Why is not working?
;; (ii-mode org-mode-map "org-mode-map")
;; (map! :n "SPC i i" (lambda () (ii-mode org-mode-map "org-mode-map")))
2020-01-16 19:03:06 +01:00
#+END_SRC
* Custom configuration
2020-01-20 15:53:32 +01:00
** Dired
#+BEGIN_SRC emacs-lisp
(setq dired-dwim-target t)
#+END_SRC
2020-06-20 13:00:00 +02:00
Peep-dired:
#+BEGIN_SRC emacs-lisp
(map! :map 'peep-dired-mode-map
:n "j" #'peep-dired-next-file
:n "k" #'peep-dired-prev-file
)
(add-hook! 'peep-dired-hook #'evil-normalize-keymaps)
(setq peep-dired-cleanup-on-disable t)
(setq peep-dired-ignored-extensions '("mkv" "iso" "mp4" "webm" "avi"))
#+END_SRC
2020-01-16 19:03:06 +01:00
** General
2020-01-23 15:10:39 +01:00
Delitimers:
2020-01-16 19:03:06 +01:00
#+BEGIN_SRC emacs-lisp
(show-paren-mode 1)
2020-01-23 15:10:39 +01:00
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
2020-01-16 19:03:06 +01:00
#+END_SRC
Cutting lines at 80th character:
#+BEGIN_SRC emacs-lisp
2020-01-20 15:53:32 +01:00
(add-hook! 'text-mode-hook #'turn-on-auto-fill)
2020-01-16 19:03:06 +01:00
(setq-default auto-fill-function 'do-auto-fill)
#+END_SRC
2020-01-20 15:53:32 +01:00
Highlight after 80:
#+BEGIN_SRC emacs-lisp
;; (require 'whitespace)
;; (setq whitespace-style '(face lines-tail))
2020-01-23 23:46:41 +01:00
;; (add-hook 'text-mode-hook
;; (setq whitespace-line-column 80)
;; ;; (global-whitespace-mode t) ; for dot on spaces
;; )
2020-01-20 15:53:32 +01:00
#+END_SRC
2020-01-23 23:46:41 +01:00
Trailing whitespaces:
2020-01-20 15:53:32 +01:00
#+BEGIN_SRC emacs-lisp
;; (setq-default show-trailing-whitespace t)
2020-01-23 23:46:41 +01:00
(setq-default indicate-empty-lines t)
(add-hook 'before-save-hook 'delete-trailing-whitespace)
2020-01-20 15:53:32 +01:00
#+END_SRC
2020-01-16 19:03:06 +01:00
Wrap lines if there is no more space in the window:
#+BEGIN_SRC emacs-lisp
(global-visual-line-mode)
#+END_SRC
Evil-surround work everywhere:
#+BEGIN_SRC emacs-lisp
(global-evil-surround-mode t)
#+END_SRC
2020-01-23 15:10:39 +01:00
Folding:
2020-01-16 19:03:06 +01:00
#+BEGIN_SRC emacs-lisp
(vimish-fold-global-mode 1)
2020-04-21 00:01:51 +02:00
(add-hook 'prog-mode-hook
(lambda ()
(if (or (derived-mode-p 'python-mode) (derived-mode-p 'haskell-mode))
(progn
(yafolding-mode)
(yafolding-hide-all)
)
(+fold/close-all)
)))
2020-01-23 15:10:39 +01:00
2020-04-30 02:35:14 +02:00
(defun yafolding-rec (todo)
2020-01-23 15:10:39 +01:00
(interactive)
(setq level (yafolding-get-indent-level))
2020-04-21 00:01:51 +02:00
(while (or (current-line-empty-p) (> level 0))
(if (current-line-empty-p)
(progn
(re-search-backward "^.")
(setq level (yafolding-get-indent-level))
)
(progn
(yafolding-go-parent-element)
(setq level (- level 1))
)
))
2020-04-30 02:35:14 +02:00
(cond ((eq todo 'hide-element) (yafolding-hide-element))
((eq todo 'hide-all) (yafolding-hide-all))
)
2020-04-21 00:01:51 +02:00
)
(defun current-line-empty-p ()
;; Spaces not included
(string-match-p "\\`$" (thing-at-point 'line)))
(defun current-line-empty2-p ()
;; Spaces included
(string-match-p "\\`\\s-*$" (thing-at-point 'line)))
2020-01-23 15:10:39 +01:00
2020-01-23 23:46:41 +01:00
(map! :map 'hs-minor-mode-map
:n "z o" #'hs-show-block
)
2020-01-23 15:10:39 +01:00
(map! :map 'yafolding-mode-map
:n "z a" #'yafolding-toggle-fold
:n "z c" #'yafolding-hide-parent-element
2020-04-30 02:35:14 +02:00
:n "z C" (lambda () (interactive) (yafolding-rec 'hide-element))
2020-05-03 11:50:14 +02:00
:n "z o" #'yafolding-show-element
2020-04-28 14:09:26 +02:00
:n "z O" #'yafolding-show-element
2020-04-30 02:35:14 +02:00
:n "z m" (lambda () (interactive) (yafolding-rec 'hide-all))
2020-01-23 15:10:39 +01:00
:n "z r" #'yafolding-show-all
)
2020-04-28 14:09:26 +02:00
#+END_SRC
2020-01-16 19:03:06 +01:00
IRC (not working):
#+BEGIN_SRC emacs-lisp
;; Default user.
(setq rcirc-default-nick "initega")
(setq rcirc-default-user-name "initega")
(setq rcirc-default-full-name "initega")
#+END_SRC
2020-04-30 02:35:14 +02:00
Eshell:
#+BEGIN_SRC emacs-lisp
(add-hook 'eshell-mode-hook (lambda ()
(if (eq company-mode nil)
(company-mode)
)
))
(setq shell-command-switch "-ic")
(defun singpolyma/term-insert-literal (key)
"Take a keypress and insert it literally into a terminal."
(interactive "cPress key:")
(term-send-raw-string (format "\e%c" key))
)
(add-hook 'term-mode-hook
(lambda ()
(interactive)
(doom-mark-buffer-as-real-h)
(map!
:i "C-#" #'singpolyma/term-insert-literal
)))
2020-04-30 02:35:14 +02:00
#+END_SRC
Aliases:
#+BEGIN_SRC emacs-lisp
(defalias 'open 'find-file)
(defalias 'openo 'find-file-other-window)
;; (apply 'eshell/alias '("config" "/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME"))
;; (add-hook 'eshell-mode-hook 'eshell-load-bashrc-aliases)
#+END_SRC
2020-05-06 12:29:35 +02:00
Interesting buffers filter:
#+BEGIN_SRC emacs-lisp
(defun my-ido-ignore-func (name)
"Ignore all non-user (a.k.a. *starred*) buffers except those listed in `my-unignored-buffers'."
(and (string-match "^\*" name)
(not (member name my-unignored-buffers))))
(setq ido-ignore-buffers '("\\` " my-ido-ignore-func))
#+END_SRC
#+BEGIN_SRC emacs-lisp
(add-hook 'calendar-load-hook
(lambda ()
(calendar-set-date-style 'european)))
(setq calendar-week-start-day 1)
#+END_SRC
2020-05-23 16:37:32 +02:00
#+BEGIN_SRC emacs-lisp
(setq flycheck-flake8-maximum-line-length 80)
#+END_SRC
2020-06-17 22:43:39 +02:00
** Personal packages
#+BEGIN_SRC emacs-lisp
(add-to-list 'load-path "~/.doom.d/lisp/")
(load "rate-sx")
(load "sunrise")
#+END_SRC
2020-01-16 19:03:06 +01:00
** Haskell
2020-01-20 15:53:32 +01:00
Haskell-mode configs:
2020-01-23 15:10:39 +01:00
# ;; Ancient code for hindent
# ;; (add-hook! 'haskell-mode-hook
# ;; #'hindent-mode
# ;; (lambda() (add-hook!
# ;; 'before-save-hook
# ;; (progn
# ;; (hindent-reformat-buffer)
# ;; (recenter-top-bottom)
# ;; ) nil 'local)))
Haskell stylish:
2020-01-20 15:53:32 +01:00
#+BEGIN_SRC emacs-lisp
(after! haskell-mode
(progn
(setq
;; Format files with Brittany instead of Stylish
haskell-mode-stylish-haskell-path "brittany"
;; Format buffer with Brittany on save
haskell-stylish-on-save t
;; Suggest removing imports
haskell-process-suggest-remove-import-lines t)))
#+END_SRC
2020-01-23 15:10:39 +01:00
Haskell-mode hook to activate minor modes (yafolding...).
2020-01-16 19:03:06 +01:00
#+BEGIN_SRC emacs-lisp
2020-01-20 15:53:32 +01:00
(add-hook 'haskell-mode-hook
(lambda ()
(interactive)
(haskell-indentation-mode)
(interactive-haskell-mode)
(yas-minor-mode)
))
(map! :map 'haskell-interactive-mode-map
:i "C-j" #'haskell-interactive-mode-history-next)
(map! :map 'haskell-interactive-mode-map
:i "C-k" #'haskell-interactive-mode-history-previous)
#+END_SRC
2020-01-16 19:03:06 +01:00
2020-01-20 15:53:32 +01:00
Haskell-interactive-mode process (change when I am on big project):
#+BEGIN_SRC emacs-lisp
;; (setq haskell-process-path-ghci "stack-ghci")
(setq haskell-process-type 'stack-ghci)
#+END_SRC
Dante configuration:
#+BEGIN_SRC emacs-lisp
(after! dante
(nconc dante-methods '(stack-ghci))
(defun dante-repl-command-line ()
'("stack-ghci"))
)
;; (setq dante-methods
;; '(styx new-impure-nix new-nix nix impure-nix new-build nix-ghci stack mafia
;; bare-cabal bare-ghci)))
(add-hook 'dante-mode-hook
'(lambda () (flycheck-add-next-checker 'haskell-dante
'(warning . haskell-hlint))))
#+END_SRC
Highlight predule:
#+BEGIN_SRC emacs-lisp
(highlight-words-on-mode 'haskell-mode prelude-symbols)
2020-01-16 19:03:06 +01:00
#+END_SRC
2020-02-08 10:52:26 +01:00
** Jupyter (ein)
#+BEGIN_SRC emacs-lisp
(setq org-babel-load-languages '((emacs-lisp . t) (ein . t)))
#+END_SRC
2020-01-16 19:03:06 +01:00
** Python
#+BEGIN_SRC emacs-lisp
(elpy-enable)
2020-04-21 00:01:51 +02:00
;; Following disabled due to high CPU usage
2020-01-16 19:03:06 +01:00
;;; Use IPython for REPL
2020-04-21 00:01:51 +02:00
;; (setq python-shell-interpreter "jupyter"
;; python-shell-interpreter-args "console --simple-prompt"
;; python-shell-prompt-detect-failure-warning nil)
;; (add-to-list 'python-shell-completion-native-disabled-interpreters
;; "jupyter")
;; (setq python-shell-interpreter "ipython"
;; python-shell-interpreter-args "-i --simple-prompt")
(setq blacken-line-length 80)
2020-03-29 16:54:56 +02:00
(add-hook 'python-mode-hook
2020-04-21 00:01:51 +02:00
(lambda ()
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
2020-04-28 14:09:26 +02:00
(yafolding-mode)
2020-04-21 00:01:51 +02:00
(setq-default python-indent 4)))
2020-01-16 19:03:06 +01:00
#+END_SRC
2020-01-23 15:10:39 +01:00
2020-01-16 19:03:06 +01:00
** Shell script
#+BEGIN_SRC emacs-lisp
(highlight-words-on-mode 'sh-mode sh-symbols)
#+END_SRC
2020-05-23 16:37:32 +02:00
** AucTex
#+BEGIN_SRC emacs-lisp
;; (add-to-list 'TeX-mode-hook #'TeX-fold-buffer)
;; (add-hook! 'tex-mode-hook #'TeX-fold-buffer)
#+END_SRC
2020-06-17 22:43:39 +02:00
** TRAMP
#+BEGIN_SRC emacs-lisp
(defun my-shell ()
(interactive)
(let ((default-directory "/ssh:initega@192.168.0.28:"))
(eshell)))
#+END_SRC
2020-01-16 19:03:06 +01:00
* Doom info
Here are some additional functions/macros that could help you configure Doom:
- `load!' for loading external *.el files relative to this one
- `use-package' for configuring packages
- `after!' for running code after a package has loaded
- `add-load-path!' for adding directories to the `load-path', where Emacs
looks when you load packages with `require' or `use-package'.
- `map!' for binding new keys
To get information about any of these functions/macros, move the cursor over
the highlighted symbol at press 'K' (non-evil users must press 'C-c g k').
This will open documentation for it, including demos of how they are used.
You can also try 'gd' (or 'C-c g d') to jump to their definition and see how
they are implemented.