From 95abbccc36394b24e55c30f3d7a93c227b3d32f5 Mon Sep 17 00:00:00 2001 From: shoshin Date: Fri, 16 Sep 2022 19:09:41 -0500 Subject: Docs: use symbol function def for project keymap --- shoshimacs.el | 13 +++++++------ shoshimacs.org | 23 ++++++++++++++--------- 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 -- cgit v1.2.3