aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshoshin <shoshin@cicadas.surf>2022-09-16 19:09:41 -0500
committershoshin <shoshin@cicadas.surf>2022-09-16 19:09:41 -0500
commit95abbccc36394b24e55c30f3d7a93c227b3d32f5 (patch)
treee4c5f4ea98c689c1e3f588d50711b074ffbfc118
parent639b5411045a408969c1af119e993f2846322ed2 (diff)
Docs: use symbol function def for project keymap
-rw-r--r--shoshimacs.el13
-rw-r--r--shoshimacs.org23
2 files changed, 21 insertions, 15 deletions
diff --git a/shoshimacs.el b/shoshimacs.el
index 8462e03..bb72c6e 100644
--- a/shoshimacs.el
+++ b/shoshimacs.el
@@ -66,11 +66,11 @@
(define-prefix-command (quote ,keymap))
(global-set-key (kbd ,leader) ,keymap)
(mapc (lambda (pair)
- (define-key ,keymap
- (kbd (if (numberp (car pair)) (number-to-string (car pair))
- (symbol-name (car pair))))
- (cadr pair)))
- (quote ,(seq-partition pairs 2)))))
+ (define-key ,keymap
+ (kbd (if (numberp (car pair)) (number-to-string (car pair))
+ (symbol-name (car pair))))
+ (cadr pair)))
+ (quote ,(seq-partition pairs 2)))))
(with-map-defkey my-key-map "M-m"
1 delete-other-windows
@@ -86,6 +86,7 @@
j describe-function
k describe-variable
n tab-next
+ p project-prefix-map
s consult-git-grep
t consult-theme
w which-key-mode
@@ -194,7 +195,7 @@
(define-key flymake-mode-map (kbd "M-p") 'flymake-goto-prev-error))
;;; Projects
-(define-key my-key-map "p" project-prefix-map)
+(setf (symbol-function 'project-prefix-map) project-prefix-map)
(package-install 'magit)
diff --git a/shoshimacs.org b/shoshimacs.org
index b627513..7b75736 100644
--- a/shoshimacs.org
+++ b/shoshimacs.org
@@ -282,11 +282,11 @@ bit of ergonomics essentially avoiding some parens and quotes 😂
(define-prefix-command (quote ,keymap))
(global-set-key (kbd ,leader) ,keymap)
(mapc (lambda (pair)
- (define-key ,keymap
- (kbd (if (numberp (car pair)) (number-to-string (car pair))
- (symbol-name (car pair))))
- (cadr pair)))
- (quote ,(seq-partition pairs 2)))))
+ (define-key ,keymap
+ (kbd (if (numberp (car pair)) (number-to-string (car pair))
+ (symbol-name (car pair))))
+ (cadr pair)))
+ (quote ,(seq-partition pairs 2)))))
(with-map-defkey my-key-map "M-m"
1 delete-other-windows
@@ -302,6 +302,7 @@ bit of ergonomics essentially avoiding some parens and quotes 😂
j describe-function
k describe-variable
n tab-next
+ p project-prefix-map
s consult-git-grep
t consult-theme
w which-key-mode
@@ -738,12 +739,16 @@ elpa. however, at the moment i must install from source:
use the built in ~project.el~ api for their features.
I've got the ~project-prefix-map~ on the key =p= in [[*with-map-defkey][my-key-map]].
-Interestingly, you have to assign the /actual/ prefix map, not the
-symbol to the keybinding. My key macro doesn't evaluate it so it doesn't
-quite work.
+Interestingly, in order to refer to a a prefix map with a quoted symbol
+like you would a command, the keymap must be in the symbol's function
+definition place. The ~project.el~ package doesn't do this, which is normally
+done with ~define-prefix-command~ (in my experience). In order to make
+this prefix map work correctly with the ~with-map-defkey~ macro, we set
+the ~symbol-function~ place on the ~project-prefix-map~ to be the value,
+the actual keymap structure, of the ~project-prefix-map~ symbol. 😵
#+begin_src emacs-lisp
- (define-key my-key-map "p" project-prefix-map)
+ (setf (symbol-function 'project-prefix-map) project-prefix-map)
#+end_src
** version control