Subject: Re: bug#63469: 29.0.90; project.el doesn't add menu-bar entries

From: Juri Linkov <[email-masked]>
Date: Fri, 19 May 2023 09:56:31 +0300

>> Is it possible to enable some formal minor mode in project-visited
>> buffers?
>
> Calculating whether a known project is associated with the buffer, we'd
> need to find it.
>
> Doing that can take non-negligible amount of time, e.g. in remote buffers,
> so we only do that on-demand, not in find-file-hook.

This mode is intended for anyone who wants to show the menu
only in project-supported buffers.  To do this, they need to
enable `global-project-mode':

```patch
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 7c51778d5d4..e6dc7aea9ca 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1883,5 +1883,30 @@ project-switch-project
     (let ((project-current-directory-override dir))
       (call-interactively command))))
 
+(easy-menu-define project-mode-menu project-prefix-map
+  "Menu for `project-mode' buffers."
+  '("Project"
+    ["List buffers" project-list-buffers
+     :help "List project buffers"]
+    ;; ...
+    ))
+
+;;;###autoload
+(define-minor-mode project-mode
+  "Toggle display of project menu in the project-aware buffers."
+  :lighter " Pro"
+  :keymap (define-keymap "<menu-bar>" project-mode-menu))
+
+(defun project-mode--turn-on ()
+  "Turn on `project-mode' in all pertinent buffers."
+  (when (project-current)
+    (project-mode 1)))
+
+;;;###autoload
+(define-globalized-minor-mode global-project-mode
+  project-mode project-mode--turn-on
+  :group 'project
+  :version "30.1")
+
 (provide 'project)
 ;;; project.el ends here
```