Subject: Re: bug#76235: [PATCH] Improve prompt for 'project-switch-project'

From: Dmitry Gutov <[email-masked]>
Date: Tue, 18 Feb 2025 04:38:08 +0200

On 17/02/2025 09:35, Juri Linkov wrote:
>>> Maybe better to make the prompt configurable
>>> (not defcustom, but only a variable,
>>> so it's easy to apply properties with face).
>>> Then I'd like to change it to just "[%s]" to save space.
>>> A longer explanatory text is more suitable for everyone
>>> who use the command infrequently.
>> Could we reuse that variable in both commands?
> Sharing the same variable would be nice.

Like this?

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 35bf66c9ffb..17a26032568 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -2017,6 +2017,12 @@ project-execute-extended-command
   (let ((default-directory (project-root (project-current t))))
     (call-interactively #'execute-extended-command)))
 
+(defvar project-command-prompt (concat
+                                "Command in `"
+                                (propertize "%s" 'face 'font-lock-string-face)
+                                "': ")
+  "Prompt format to use for choosing a command by key or key sequence.")
+
 ;;;###autoload
 (defun project-any-command (&optional overriding-map prompt-format)
   "Run the next command in the current project.
@@ -2032,7 +2038,7 @@ project-any-command
 from that map which will take priority over the global ones."
   (interactive)
   (let* ((pr (project-current t))
-         (prompt-format (or prompt-format "[execute in %s]:"))
+         (prompt-format (or prompt-format project-command-prompt))
          (command (let ((overriding-terminal-local-map overriding-map))
                     (key-binding (read-key-sequence
                                   (format prompt-format (project-root pr)))
@@ -2247,10 +2253,8 @@ project--switch-project-command
                                        (help-key-description choice nil)))))
         (setq choice (read-key-sequence (concat
                                          (if dir
-                                             (format-message "Command in `%s': "
-                                                             (propertize
-                                                              dir 'face
-                                                              'font-lock-string-face))
+                                             (format-message project-command-prompt
+                                                             dir)
                                            "Command: ")
                                          prompt)))
         (when (setq command (lookup-key commands-map choice))