Subject: Re: bug#41890: 28.0.50; [PATCH]: Add bindings for project.el

From: Theodor Thornhill <[email-masked]>
Date: Tue, 16 Jun 2020 19:07:32 +0000

Hi and thanks again for tips!

> This should be:
>
>   (defvar project-prefix-map
>     (let ((map (make-sparse-keymap)))
>       (define-key map ...)
>       ...
>       map)
>     "...")
>
>   (define-key ctl-x-map "p" project-prefix-map)
>
> See the end of (info "(elisp) Tips for Defining").
>
> Maybe it should also be autoloaded.

Below is another patch with your suggestions incorporated. Is it correct to also autoload the (define-key ctl-x-map "p" project-prefix-map)?

Theo

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index f3df44fa7b..d3fb34d925 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -107,6 +107,24 @@ project-find-functions
 (defvar project-current-inhibit-prompt nil
   "Non-nil to skip prompting the user in `project-current'.")
 
+;;;###autoload
+(defvar project-prefix-map
+  (let ((map (make-sparse-keymap)))
+    (define-key map "f" 'project-find-file)
+    (define-key map "b" 'project-switch-to-buffer)
+    (define-key map "s" 'project-shell)
+    (define-key map "d" 'project-dired)
+    (define-key map "v" 'project-vc-dir)
+    (define-key map "c" 'project-compile)
+    (define-key map "e" 'project-eshell)
+    (define-key map "p" 'project-switch-project)
+    (define-key map "g" 'project-find-regexp)
+    (define-key map "r" 'project-query-replace-regexp))
+  "Keymap for project commands.")
+
+;;;###autoload
+(define-key ctl-x-map "p" project-prefix-map)
+
 ;;;###autoload
 (defun project-current (&optional maybe-prompt dir)
   "Return the project instance in DIR or `default-directory'.