[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/project-switching c8cca68 04/15: Use an alist instead of a keyma
From: |
Simen Heggestøyl |
Subject: |
feature/project-switching c8cca68 04/15: Use an alist instead of a keymap |
Date: |
Tue, 26 May 2020 11:43:18 -0400 (EDT) |
branch: feature/project-switching
commit c8cca68751ac3ebd702ab809bc2bb2cc352a190e
Author: Dmitry Gutov <address@hidden>
Commit: Simen Heggestøyl <address@hidden>
Use an alist instead of a keymap
* lisp/progmodes/project.el:
(project--switch-alist): New variable to use instead of
project-switch-keymap, which remove. Update all references.
---
lisp/progmodes/project.el | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 3e943ca..7209246 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -776,10 +776,10 @@ It's also possible to enter an arbitrary directory."
;;; Project switching
-(defvar project-switch-keymap (make-sparse-keymap)
- "Keymap of commands for \"switching\" to a project.
+(defvar project--switch-alist nil
+ "Association list mapping characters to commands.
Used by `project-switch-project' to construct a dispatch menu of
-commands available for \"switching\" to another project.")
+commands available upon \"switching\" to another project.")
;;;###autoload
(defun project-dired ()
@@ -802,7 +802,8 @@ commands available for \"switching\" to another project.")
SYMBOL should stand for a function to be invoked by the key KEY.
LABEL is used to distinguish the function in the dispatch menu."
(function-put symbol 'dispatch-label label)
- (define-key project-switch-keymap key symbol))
+ ;; XXX: It could host the label as well now.
+ (add-to-list 'project--switch-alist `(,key . ,symbol)))
(project-add-switch-command
'project-find-file "f" "Find file")
@@ -816,12 +817,13 @@ LABEL is used to distinguish the function in the dispatch
menu."
(defun project--keymap-prompt ()
"Return a prompt for the project swithing dispatch menu."
(let ((prompt ""))
- (map-keymap
- (lambda (event value)
- (let ((key (propertize (key-description `(,event)) 'face 'bold))
- (desc (function-get value 'dispatch-label)))
+ (mapc
+ (lambda (entry)
+ (pcase-let* ((`(,char . ,symbol) entry)
+ (key (propertize (key-description `(,char)) 'face 'bold))
+ (desc (function-get symbol 'dispatch-label)))
(setq prompt (concat (format "[%s] %s " key desc) prompt))))
- project-switch-keymap)
+ project--switch-alist)
prompt))
;;;###autoload
@@ -834,12 +836,12 @@ and presented in a dispatch menu."
(choice nil))
(while (not (and choice
(or (equal choice (kbd "C-g"))
- (lookup-key project-switch-keymap choice))))
+ (assoc choice project--switch-alist))))
(setq choice (read-key-sequence (project--keymap-prompt))))
(if (equal choice (kbd "C-g"))
(message "Quit")
(let ((default-directory dir))
- (funcall (lookup-key project-switch-keymap choice))))))
+ (funcall (assoc-default choice project--switch-alist))))))
(provide 'project)
;;; project.el ends here
- branch feature/project-switching created (now 449810b), Simen Heggestøyl, 2020/05/26
- feature/project-switching afb7602 01/15: Add project switching functionality, Simen Heggestøyl, 2020/05/26
- feature/project-switching 9422fb5 03/15: Improve project name completion, Simen Heggestøyl, 2020/05/26
- feature/project-switching c8cca68 04/15: Use an alist instead of a keymap,
Simen Heggestøyl <=
- feature/project-switching afb96da 05/15: Move project-dired and project-eshell higher, Simen Heggestøyl, 2020/05/26
- feature/project-switching 02e1ee9 06/15: Integrate project-switch-project with project-find-regexp, Simen Heggestøyl, 2020/05/26
- feature/project-switching 46bb2cb 07/15: Change dispatch binding of 'project-find-regexp', Simen Heggestøyl, 2020/05/26
- feature/project-switching 0db801a 11/15: Update the Emacs manual with recent project.el changes, Simen Heggestøyl, 2020/05/26
- feature/project-switching e37e6c8 13/15: Some copy edits, Simen Heggestøyl, 2020/05/26
- feature/project-switching 9f88356 02/15: Simplify a little, and avoid duplicate commands, Simen Heggestøyl, 2020/05/26
- feature/project-switching c6f56bd 08/15: Turn project switch menu var into a public alist, Simen Heggestøyl, 2020/05/26
- feature/project-switching 7082468 10/15: Rename 'project-switch-menu' to 'project-switch-commands', Simen Heggestøyl, 2020/05/26
- feature/project-switching 0b057ca 12/15: Teach project-current to inhibit the prompt, Simen Heggestøyl, 2020/05/26
- feature/project-switching 449810b 15/15: Avoid adding the empty string to the project list, Simen Heggestøyl, 2020/05/26