unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#69566: Context menu for project
@ 2024-03-05 16:54 Juri Linkov
  2024-03-08 22:57 ` Dmitry Gutov
  0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2024-03-05 16:54 UTC (permalink / raw)
  To: 69566

Tags: patch

diff --git a/lisp/mouse.el b/lisp/mouse.el
index d1b06c2040d..d5c33828846 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -393,6 +393,7 @@ context-menu-functions
                   (function-item context-menu-local)
                   (function-item context-menu-minor)
                   (function-item context-menu-buffers)
+                  (function-item context-menu-project)
                   (function-item context-menu-vc)
                   (function-item context-menu-ffap)
                   (function-item hi-lock-context-menu)
@@ -527,6 +534,12 @@ context-menu-buffers
               (mouse-buffer-menu-keymap))
   menu)
 
+(defun context-menu-project (menu _click)
+  "Populate MENU with project commands."
+  (define-key-after menu [separator-project] menu-bar-separator)
+  (define-key-after menu [project-menu] (bound-and-true-p project-menu-entry))
+  menu)
+
 (defun context-menu-vc (menu _click)
   "Populate MENU with Version Control commands."
   (define-key-after menu [separator-vc] menu-bar-separator)





^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#69566: Context menu for project
  2024-03-05 16:54 bug#69566: Context menu for project Juri Linkov
@ 2024-03-08 22:57 ` Dmitry Gutov
  2024-03-08 23:00   ` Dmitry Gutov
  0 siblings, 1 reply; 8+ messages in thread
From: Dmitry Gutov @ 2024-03-08 22:57 UTC (permalink / raw)
  To: Juri Linkov, 69566

On 05/03/2024 18:54, Juri Linkov wrote:
> +  (define-key-after menu [project-menu] (bound-and-true-p project-menu-entry))

This variable will probably always be bound (and likely non-nil), given 
than mouse.el is never distributed separately or used with older 
versions of Emacs.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#69566: Context menu for project
  2024-03-08 22:57 ` Dmitry Gutov
@ 2024-03-08 23:00   ` Dmitry Gutov
  2024-03-10 17:28     ` Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: Dmitry Gutov @ 2024-03-08 23:00 UTC (permalink / raw)
  To: Juri Linkov, 69566

On 09/03/2024 00:57, Dmitry Gutov wrote:
> On 05/03/2024 18:54, Juri Linkov wrote:
>> +  (define-key-after menu [project-menu] (bound-and-true-p 
>> project-menu-entry))
> 
> This variable will probably always be bound (and likely non-nil), given 
> than mouse.el is never distributed separately or used with older 
> versions of Emacs.

Ah, I guess you might be handling the case when project is not loaded 
yet. Perhaps we should autoload something, so that its commands are in 
the context menu anyway?

You could even copy the variable's definition to mouse.el, if that's easier.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#69566: Context menu for project
  2024-03-08 23:00   ` Dmitry Gutov
@ 2024-03-10 17:28     ` Juri Linkov
  2024-03-10 17:52       ` Dmitry Gutov
  0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2024-03-10 17:28 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 69566

>>> +  (define-key-after menu [project-menu] (bound-and-true-p
>>> project-menu-entry))
>> This variable will probably always be bound (and likely non-nil), given
>> than mouse.el is never distributed separately or used with older versions
>> of Emacs.
>
> Ah, I guess you might be handling the case when project is not loaded
> yet. Perhaps we should autoload something, so that its commands are in the
> context menu anyway?
>
> You could even copy the variable's definition to mouse.el, if that's easier.

Copying it to mouse.el or menu-bar.el makes sense since it will remove
another 'bound-and-true-p' from 'menu-bar-project-menu':

  (defvar project-menu-entry
    `(menu-item "Project" ,(bound-and-true-p menu-bar-project-menu)))

Both mouse.el and menu-bar.el are preloaded.

But the problem is that by its name prefix 'project-'
it belongs to project.el.  Or maybe rename it to
'menu-bar-project-entry'?





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#69566: Context menu for project
  2024-03-10 17:28     ` Juri Linkov
@ 2024-03-10 17:52       ` Dmitry Gutov
  2024-03-12 17:18         ` Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: Dmitry Gutov @ 2024-03-10 17:52 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 69566

On 10/03/2024 19:28, Juri Linkov wrote:
> But the problem is that by its name prefix 'project-'
> it belongs to project.el.  Or maybe rename it to
> 'menu-bar-project-entry'?

Yes, I guess something like that.





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#69566: Context menu for project
  2024-03-10 17:52       ` Dmitry Gutov
@ 2024-03-12 17:18         ` Juri Linkov
  2024-03-13 16:36           ` Dmitry Gutov
  0 siblings, 1 reply; 8+ messages in thread
From: Juri Linkov @ 2024-03-12 17:18 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 69566

[-- Attachment #1: Type: text/plain, Size: 220 bytes --]

>> But the problem is that by its name prefix 'project-'
>> it belongs to project.el.  Or maybe rename it to
>> 'menu-bar-project-entry'?
>
> Yes, I guess something like that.

Ok, here is with 'menu-bar-project-item':


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: menu-bar-project-item.patch --]
[-- Type: text/x-diff, Size: 2520 bytes --]

diff --git a/lisp/menu-bar.el b/lisp/menu-bar.el
index 5b290899ff5..320fabb54cf 100644
--- a/lisp/menu-bar.el
+++ b/lisp/menu-bar.el
@@ -1838,6 +1838,9 @@ menu-bar-project-menu
     (bindings--define-key menu [project-open-file] '(menu-item "Open File..." project-find-file :help "Open an existing file that belongs to current project"))
     menu))
 
+(defvar menu-bar-project-item
+  `(menu-item "Project" ,menu-bar-project-menu))
+
 (defun menu-bar-read-mail ()
   "Read mail using `read-mail-command'."
   (interactive)
@@ -1925,7 +1928,7 @@ menu-bar-tools-menu
                   :help "Start language server suitable for this buffer's major-mode"))
 
     (bindings--define-key menu [project]
-      `(menu-item "Project" ,menu-bar-project-menu))
+      menu-bar-project-item)
 
     (bindings--define-key menu [ede]
       '(menu-item "Project Support (EDE)"
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 26835437c08..cef88dede8a 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -393,6 +393,7 @@ context-menu-functions
                   (function-item context-menu-local)
                   (function-item context-menu-minor)
                   (function-item context-menu-buffers)
+                  (function-item context-menu-project)
                   (function-item context-menu-vc)
                   (function-item context-menu-ffap)
                   (function-item hi-lock-context-menu)
@@ -533,6 +534,12 @@ context-menu-buffers
               (mouse-buffer-menu-keymap))
   menu)
 
+(defun context-menu-project (menu _click)
+  "Populate MENU with project commands."
+  (define-key-after menu [separator-project] menu-bar-separator)
+  (define-key-after menu [project-menu] menu-bar-project-item)
+  menu)
+
 (defun context-menu-vc (menu _click)
   "Populate MENU with Version Control commands."
   (define-key-after menu [separator-vc] menu-bar-separator)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 9622b1b6768..e2559617c20 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -2140,12 +2143,10 @@ project-mode-line
   :group 'project
   :version "30.1")
 
-(defvar project-menu-entry
-  `(menu-item "Project" ,(bound-and-true-p menu-bar-project-menu)))
-
 (defvar project-mode-line-map
   (let ((map (make-sparse-keymap)))
-    (define-key map [mode-line down-mouse-1] project-menu-entry)
+    (define-key map [mode-line down-mouse-1]
+                (bound-and-true-p menu-bar-project-item))
     map))
 
 (defvar project-mode-line-face nil

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* bug#69566: Context menu for project
  2024-03-12 17:18         ` Juri Linkov
@ 2024-03-13 16:36           ` Dmitry Gutov
  2024-03-14 17:29             ` Juri Linkov
  0 siblings, 1 reply; 8+ messages in thread
From: Dmitry Gutov @ 2024-03-13 16:36 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 69566

On 12/03/2024 19:18, Juri Linkov wrote:
>>> But the problem is that by its name prefix 'project-'
>>> it belongs to project.el.  Or maybe rename it to
>>> 'menu-bar-project-entry'?
>> Yes, I guess something like that.
> Ok, here is with 'menu-bar-project-item':

Looking good, thanks!





^ permalink raw reply	[flat|nested] 8+ messages in thread

* bug#69566: Context menu for project
  2024-03-13 16:36           ` Dmitry Gutov
@ 2024-03-14 17:29             ` Juri Linkov
  0 siblings, 0 replies; 8+ messages in thread
From: Juri Linkov @ 2024-03-14 17:29 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 69566

close 69566 30.0.50
thanks

>>>> But the problem is that by its name prefix 'project-'
>>>> it belongs to project.el.  Or maybe rename it to
>>>> 'menu-bar-project-entry'?
>>> Yes, I guess something like that.
>> Ok, here is with 'menu-bar-project-item':
>
> Looking good, thanks!

So now pushed.





^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-03-14 17:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-05 16:54 bug#69566: Context menu for project Juri Linkov
2024-03-08 22:57 ` Dmitry Gutov
2024-03-08 23:00   ` Dmitry Gutov
2024-03-10 17:28     ` Juri Linkov
2024-03-10 17:52       ` Dmitry Gutov
2024-03-12 17:18         ` Juri Linkov
2024-03-13 16:36           ` Dmitry Gutov
2024-03-14 17:29             ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).