config

Personal configuration.
git clone git://code.dwrz.net/config
Log | Files | Refs

commit a3c581f0523acb6ab96d7ce58487e1b13c557e8a
parent 582d05c6df6fd7c08555fdd84ae40b72af408281
Author: dwrz <dwrz@dwrz.net>
Date:   Sat,  3 Feb 2024 02:52:15 +0000

Update Emacs init

Diffstat:
Memacs/init.el | 251++++++++++++++++++++++++++++++++++++++-----------------------------------------
1 file changed, 122 insertions(+), 129 deletions(-)

diff --git a/emacs/init.el b/emacs/init.el @@ -57,6 +57,16 @@ (font-lock-add-keywords nil '(("\\<\\(FIX\\|TODO\\|NB\\)" 1 font-lock-warning-face t)))) +(defun dwrz-insert-date () + "Insert date at point." + (interactive) + (insert (format-time-string "%Y%m%d"))) + +(defun dwrz-insert-timestamp () + "Insert timestamp at point." + (interactive) + (insert (format-time-string "%FT%T%z"))) + (defun dwrz-org-capture-at-point () "Insert an org capture template at point." (interactive) @@ -204,7 +214,7 @@ (corfu-auto-prefix 2) (corfu-cycle t) (corfu-history-mode 1) - (corfu-on-exact-match 'quit) + (corfu-on-exact-match 'show) (corfu-popupinfo-delay '(1.25 . 0.5)) (corfu-quit-no-match t) (corfu-scroll-margin 0) @@ -259,7 +269,7 @@ :ensure t) (use-package elisp-mode - :config (setq-local indent-tabs-mode nil) ;; FIX + :config (setq-local indent-tabs-mode nil) :hook (emacs-lisp-mode . eldoc-mode) :ensure nil) @@ -340,8 +350,6 @@ :config (global-hl-line-mode t) :ensure nil) -(use-package hydra :ensure t) - (use-package ispell :config (setq ispell-program-name "/usr/bin/aspell" ispell-dictionary "en_US" @@ -641,6 +649,8 @@ (use-package paren :config (show-paren-mode t) :ensure nil) +(use-package password-store :ensure t) + (use-package plantuml-mode :config (setq org-plantuml-jar-path (expand-file-name "/usr/share/java/plantuml/plantuml.jar")) @@ -726,22 +736,6 @@ (use-package subr-x :init (defalias 'yes-or-no-p 'y-or-n-p) :ensure nil) -;; TODO: investigate yasnippet or tempel. -;; https://github.com/minad/tempel -;; (use-package tempel -;; :bind (("M-+" . tempel-complete) -;; ("M-*" . tempel-insert)) -;; :custom (tempel-trigger-prefix ".") -;; :init -;; (defun tempel-setup-capf () -;; (setq-local completion-at-point-functions -;; (cons #'tempel-expand -;; completion-at-point-functions))) -;; (add-hook 'conf-mode-hook 'tempel-setup-capf) -;; (add-hook 'prog-mode-hook 'tempel-setup-capf) -;; (add-hook 'text-mode-hook 'tempel-setup-capf) -;; :ensure t) - (use-package text-mode :hook ((text-mode . flyspell-mode) (text-mode . visual-line-mode)) @@ -775,6 +769,12 @@ :init (vertico-mode) :ensure t) +(use-package vundo + :config + (setq vundo-glyph-alist vundo-unicode-symbols + vundo-compact-display t) + :ensure t) + (use-package visual-fill-column :config (setq split-window-preferred-function 'visual-fill-column-split-window-sensibly) @@ -794,6 +794,11 @@ (use-package wgrep :defer t :ensure t) +(use-package which-key + :init (setq which-key-idle-delay 0.25) + :config (which-key-mode) + :ensure t) + (use-package window :config (setq split-height-threshold nil split-width-threshold 160) @@ -803,123 +808,111 @@ (use-package yaml-mode :ensure t) -;; Hydras -;; TODO: replace with defvar-keymap. -(defhydra hydra-cape (:color blue) - ("q" nil "quit" :column "quit") - ("&" cape-sgml "sgml" :column "cape") - (":" cape-emoji "emoji" :column "cape") - ("a" cape-abbrev "abbrev" :column "cape") - ("d" cape-dabbrev "dabbrev" :column "cape") - ("e" cape-elisp-block "elisp-block" :column "cape") - ("f" cape-file "file" :column "cape") - ("h" cape-history "history" :column "cape") - ("k" cape-keyword "keyword" :column "cape") - ("l" cape-line "line" :column "cape") - ("e" cape-elisp-symbol "elisp-symbol" :column "cape") - ("r" cape-rfc1345 "RFC 1345" :column "cape") - ("w" cape-dict "dict" :column "cape")) - -(defhydra hydra-consult (:color blue) - ("q" nil "quit" :column "quit") - ("a" (lambda () (interactive) (consult-notmuch-address t nil)) - "notmuch" :column "consult") - ("c" consult-mark "mark" :column "consult") - ("f" consult-find "find" :column "consult") - ("g" consult-grep "grep" :column "consult") - ("i" consult-imenu-multi "imenu" :column "consult") - ("k" consult-global-mark "mark" :column "consult") - ("m" consult-line-multi "line-multi" :column "consult") - ("n" consult-notmuch "notmuch" :column "consult") - ("o" consult-org-heading "org" :column "consult") - ("r" consult-ripgrep "ripgrep" :column "consult") - ("t" consult-outline "outline" :column "consult") - ("v" consult-git-grep "git-grep" :column "consult")) - -(defhydra hydra-exec (:color blue) - ("q" nil "quit" :column "quit") - ("s" dwrz-shell-in-current-directory "shell" :column "execute")) - -(defhydra hydra-highlight (:color blue) - ("q" nil "quit" :column "highlight") - ("s" highlight-symbol-at-point "symbol" :color blue :column "do") - ("l" highlight-lines-matching-regexp "lines" :color blue :column "do") - ("p" highlight-phrase "phrase" :color blue :column "do") - ("r" highlight-regexp "regex" :color blue :column "do") - ("u" unhighlight-regexp "unhighlight" :color blue :column "undo")) - -(defhydra hydra-org (:color blue) - ("q" nil "quit" :column "quit") - ("a" (dwrz-switch-org-ctx "all") "all" :column "ctx") - ("c" (dwrz-switch-org-ctx "chimerical") "chimerical" :column "ctx") - ("d" (dwrz-switch-org-ctx "dwrz") "dwrz" :column "ctx") - ("e" (dwrz-switch-org-ctx "eti") "eti" :column "ctx")) - -(defhydra hydra-point (:color blue) - ("q" nil "quit" :column "point") - ("e" hippie-expand "expand" :color red :column "do") - ("k" kill-word "delete word" :column "do") - ("s" ispell-word "spell" :column "do") - ("d" (insert (format-time-string "%Y%m%d")) "date" :column "insert") - ("t" (insert (format-time-string "%FT%T%z")) "timestamp" :column "insert")) - -(defhydra hydra-region (:color red) - ("q" nil "quit" :column "region") - ("o" comment-or-uncomment-region "comment" :column "edit") - ("r" reverse-region "reverse" :column "edit") - ("s" sort-lines "sort" :column "edit") - ("c" rot13-region "cipher" :column "format") - ("d" downcase-region "downcase" :column "format") - ("u" upcase-region "upcase" :column "format") - ("U" prot-simple-unfill-region-or-paragraph "unfill" :column "fill") - ("f" fill-region "fill" :column "fill")) - -(defhydra hydra-windows (:color pink) - ("q" nil "quit" :column "windows") - ("b" balance-windows "balance" :column "window") - ("t" enlarge-window "taller" :column "window") - ("n" shrink-window-horizontally "narrow" :column "window") - ("l" shrink-window "lower" :column "window") - ("w" enlarge-window-horizontally "widen" :column "window") - ("-" text-scale-decrease "out" :column "zoom") - ("+" text-scale-increase "in" :column "zoom") - ("=" (text-scale-increase 0) "reset" :column "zoom")) - -(defhydra hydra-meta (:color blue) - ("q" nil "quit" :column "meta") - ("p" hydra-point/body "point" :column "area") - ("r" hydra-region/body "region" :column "area") - ("w" hydra-windows/body "windows" :column "area") - ("c" hydra-cape/body "cape" :column "hydras") - ("e" hydra-exec/body "exec" :column "hydras") - ("h" hydra-highlight/body "highlight" :column "hydras") - ("o" hydra-org/body "org" :column "hydras") - ("s" hydra-consult/body "consult" :column "hydras")) +(use-package yasnippet :config (yas-global-mode 1) :ensure t) + +(use-package yasnippet-capf + :after cape + :config + (add-to-list 'completion-at-point-functions #'yasnippet-capf) + :ensure t) + +;; Keymaps +(defvar-keymap dwrz-cape-map + "&" #'cape-sgml + ":" #'cape-emoji + "a" #'cape-abbrev + "d" #'cape-dabbrev + "e" #'cape-elisp-block + "f" #'cape-file + "h" #'cape-history + "k" #'cape-keyword + "l" #'cape-line + "r" #'cape-rfc1345 + "s" #'cape-elisp-symbol + "w" #'cape-dict) + +(defvar-keymap dwrz-exec-map + "s" #'dwrz-shell-in-current-directory) + +(defvar-keymap dwrz-org-map + "a" #'(lambda () (interactive) (dwrz-switch-org-ctx "all")) + "c" #'(lambda () (interactive) (dwrz-switch-org-ctx "chimerical")) + "d" #'(lambda () (interactive) (dwrz-switch-org-ctx "dwrz")) + "e" #'(lambda () (interactive) (dwrz-switch-org-ctx "eti"))) + +(defvar-keymap dwrz-region-map + "U" #'prot-simple-unfill-region-or-paragraph + "c" #'rot13-region + "d" #'downcase-region + "f" #'fill-region + "o" #'comment-or-uncomment-region + "r" #'reverse-region + "s" #'sort-lines + "u" #'upcase-region) + +(defvar-keymap dwrz-windows-map + "+" #'text-scale-increase + "-" #'text-scale-decrease + "=" (cons "reset" #'(lambda () (interactive) (text-scale-increase 0))) + "b" #'balance-windows + "l" #'shrink-window + "n" #'shrink-window-horizontally + "t" #'enlarge-window + "w" #'enlarge-window-horizontally) + +(defvar-keymap dwrz-highlight-map + :doc "Prefix keymap for highlight." + :name "Highlight" + "l" #'highlight-lines-matching-regexp + "p" #'highlight-phrase + "r" #'highlight-regexp + "s" #'highlight-symbol-at-point + "u" #'unhighlight-regexp) + +(defvar-keymap dwrz-point-map + :doc "Prefix keymap for point." + :name "Point" + "d" (cons "date" #'dwrz-insert-date) + "e" #'hippie-expand + "k" #'kill-word + "s" #'ispell-word + "t" (cons "timestamp" #'dwrz-insert-timestamp)) + +(defvar-keymap dwrz-search-map + "a" #'(lambda () (interactive) (consult-notmuch-address t nil)) + "c" #'consult-mark + "f" #'consult-find + "g" #'consult-grep + "i" #'consult-imenu-multi + "k" #'consult-global-mark + "m" #'consult-line-multi + "n" #'consult-notmuch + "o" #'consult-org-heading + "r" #'consult-ripgrep + "t" #'consult-outline + "v" #'consult-git-grep) + +(defvar-keymap dwrz-prefix-map + :doc "Prefix keymap with multiple subkeymaps." + :name "dwrz prefix" + "c" (cons "cape" dwrz-cape-map) + "e" (cons "exec" dwrz-exec-map) + "h" (cons "highlight" dwrz-highlight-map) + "o" (cons "org" dwrz-org-map) + "p" (cons "point" dwrz-point-map) + "r" (cons "region" dwrz-region-map) + "s" (cons "search" dwrz-search-map) + "w" (cons "window" dwrz-windows-map)) ;; KEYBINDINGS +(global-set-key (kbd "C-:") dwrz-prefix-map) (global-set-key (kbd "C-c #") 'display-line-numbers-mode) (global-set-key (kbd "C-c b") 'ibuffer) (global-set-key (kbd "C-c c") 'dwrz-org-capture-at-point) -(global-set-key (kbd "C-c d") nil) (global-set-key (kbd "C-c e") 'execute-extended-command) -(global-set-key (kbd "C-c f") nil) (global-set-key (kbd "C-c h") 'hippie-expand) -(global-set-key (kbd "C-c i") nil) (global-set-key (kbd "C-c j") 'jump-to-register) -(global-set-key (kbd "C-c k") nil) (global-set-key (kbd "C-c l") 'org-store-link) -(global-set-key (kbd "C-c m") 'hydra-meta/body) -(global-set-key (kbd "C-c n") nil) -(global-set-key (kbd "C-c p") 'hydra-point/body) -(global-set-key (kbd "C-c q") nil) -(global-set-key (kbd "C-c r") 'hydra-region/body) -(global-set-key (kbd "C-c s") 'hydra-consult/body) -(global-set-key (kbd "C-c t") nil) -(global-set-key (kbd "C-c u") nil) -(global-set-key (kbd "C-c v") nil) -(global-set-key (kbd "C-c w") 'hydra-windows/body) -(global-set-key (kbd "C-c x") 'hydra-org/body) -(global-set-key (kbd "C-c y") nil) -(global-set-key (kbd "C-c z") nil) (global-set-key (kbd "C-x 9") 'dwrz-split-window-two-thirds) (global-set-key (kbd "C-x C-b") 'ibuffer) +(keymap-set global-map "C-;" dwrz-prefix-map)