summaryrefslogtreecommitdiff
path: root/.emacs
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@gmail.com>2020-09-18 13:22:52 +0200
committerKévin Le Gouguec <kevin.legouguec@gmail.com>2020-09-18 15:15:02 +0200
commit4f27c30d9b736d7d9be80d5d74092c6d3fcb5bc1 (patch)
treef1856ba5968ff65c75ead5db437171fa75076d25 /.emacs
parent998ed49ccad7ecab877e37beda650fbc159ac83b (diff)
downloaddotfiles-4f27c30d9b736d7d9be80d5d74092c6d3fcb5bc1.tar.xz
Start defining proper prefix commands
This allows - which-key to display a helpful symbol instead of "+prefix", - C-h b to cross-link to the keymap's docstring.
Diffstat (limited to '.emacs')
-rw-r--r--.emacs25
1 files changed, 21 insertions, 4 deletions
diff --git a/.emacs b/.emacs
index 5190636..d25d2ef 100644
--- a/.emacs
+++ b/.emacs
@@ -127,14 +127,31 @@
(require 'project)
(magit-status (project-prompt-project-dir)))
+(defmacro my/define-prefix-command (name doc bindings)
+ (declare (indent defun))
+ `(defvar ,name
+ (let ((map (define-prefix-command ',name)))
+ (pcase-dolist (`(,key . ,fun) ,bindings)
+ (define-key map key fun))
+ map)
+ ,doc))
+
+(my/define-prefix-command my/display-map
+ "Keymap for display-related commands."
+ '(("t" . toggle-truncate-lines)
+ ("v" . visual-line-mode)))
+
+(my/define-prefix-command my/input-map
+ "Keymap for input methods shortcuts."
+ `(("t" . ,(my/make-input-toggle TeX))
+ ("u" . ,(my/make-input-toggle my/symbols))))
+
;; C-c [[:alpha:]] is reserved for users - let's make good use of it.
(global-set-key (kbd "C-c c") 'compile)
-(global-set-key (kbd "C-c d t") 'toggle-truncate-lines)
-(global-set-key (kbd "C-c d v") 'visual-line-mode)
+(global-set-key (kbd "C-c d") 'my/display-map)
(global-set-key (kbd "C-c e f") 'auto-fill-mode)
-(global-set-key (kbd "C-c i t") (my/make-input-toggle TeX))
-(global-set-key (kbd "C-c i u") (my/make-input-toggle my/symbols))
+(global-set-key (kbd "C-c i") 'my/input-map)
(global-set-key (kbd "C-c k f") 'my/kill-ring-filename)
(global-set-key (kbd "C-c k |") 'my/kill-ring-pipe-region)
(global-set-key (kbd "C-c k !") 'my/kill-ring-shell)