GNU bug report logs - #78660
[PATCH] Add context menu for commenting in prog-mode

Previous Next

Package: emacs;

Reported by: Billy Lei <LeiYiXia29 <at> outlook.com>

Date: Sun, 1 Jun 2025 05:30:07 UTC

Severity: normal

Tags: patch

To reply to this bug, email your comments to 78660 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#78660; Package emacs. (Sun, 01 Jun 2025 05:30:08 GMT) Full text and rfc822 format available.

Acknowledgement sent to Billy Lei <LeiYiXia29 <at> outlook.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 01 Jun 2025 05:30:08 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Billy Lei <LeiYiXia29 <at> outlook.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Add context menu for commenting in prog-mode
Date: Sun, 1 Jun 2025 13:23:35 +0800
[Message part 1 (text/plain, inline)]
Though context menu is supported in emacs at present, many modes that 
supports it still lacks some functions (like commenting, toggling bookmark).

This patch is a small update, which add context menu for commenting in 
prog-mode.
[0001-lisp-progmodes-prog-mode.el-prog-context-menu-Add-co.patch (text/plain, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78660; Package emacs. (Sun, 01 Jun 2025 07:04:03 GMT) Full text and rfc822 format available.

Message #8 received at 78660 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Billy Lei <LeiYiXia29 <at> outlook.com>
Cc: 78660 <at> debbugs.gnu.org
Subject: Re: bug#78660: [PATCH] Add context menu for commenting in prog-mode
Date: Sun, 01 Jun 2025 09:49:45 +0300
> Though context menu is supported in emacs at present, many modes that
> supports it still lacks some functions (like commenting, toggling
> bookmark).
>
> This patch is a small update, which add context menu for commenting in
> prog-mode.

If our goal is to stuff context menus with all possible commands,
then this patch is ok.  Only suggest at least to group commands
by submenu trees.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78660; Package emacs. (Sun, 01 Jun 2025 10:30:02 GMT) Full text and rfc822 format available.

Message #11 received at 78660 <at> debbugs.gnu.org (full text, mbox):

From: Lei Billy <LeiYiXia29 <at> outlook.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: "78660 <at> debbugs.gnu.org" <78660 <at> debbugs.gnu.org>
Subject: Re: bug#78660: [PATCH] Add context menu for commenting in prog-mode
Date: Sun, 1 Jun 2025 10:29:34 +0000
在 2025/6/1 14:49, Juri Linkov 写道:
>> Though context menu is supported in emacs at present, many modes that
>> supports it still lacks some functions (like commenting, toggling
>> bookmark).
>> This patch is a small update, which add context menu for commenting in
>> prog-mode.
> If our goal is to stuff context menus with all possible commands,
> then this patch is ok.  Only suggest at least to group commands
> by submenu trees.

While there are a wide range of commands, I think only the common ones should be added to the context menu. I don't think stuffing context menus with all possible commands is a good choice, this will cause users end up finding commands in submenus.

I think we can refer to software like notepad++, notepad3, etc to see which commands are worth to be added to the context menu.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78660; Package emacs. (Sun, 01 Jun 2025 16:54:04 GMT) Full text and rfc822 format available.

Message #14 received at 78660 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lei Billy <LeiYiXia29 <at> outlook.com>
Cc: "78660 <at> debbugs.gnu.org" <78660 <at> debbugs.gnu.org>
Subject: Re: bug#78660: [PATCH] Add context menu for commenting in prog-mode
Date: Sun, 01 Jun 2025 19:47:25 +0300
>>> Though context menu is supported in emacs at present, many modes that
>>> supports it still lacks some functions (like commenting, toggling
>>> bookmark).
>>> This patch is a small update, which add context menu for commenting in
>>> prog-mode.
>> If our goal is to stuff context menus with all possible commands,
>> then this patch is ok.  Only suggest at least to group commands
>> by submenu trees.
>
> While there are a wide range of commands, I think only the common ones
> should be added to the context menu. I don't think stuffing context
> menus with all possible commands is a good choice, this will cause
> users end up finding commands in submenus.

Or like there is for example 'treesit-font-lock-level' that defines
how much fontification the user wants, we could add an option that
defines how many menu items the user wants to add to the context menu.

> I think we can refer to software like notepad++, notepad3, etc to see
> which commands are worth to be added to the context menu.

Indeed, we could look elsewhere to get an idea for good balance
on the menu size.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78660; Package emacs. (Wed, 04 Jun 2025 17:43:02 GMT) Full text and rfc822 format available.

Message #17 received at 78660 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Lei Billy <LeiYiXia29 <at> outlook.com>
Cc: "78660 <at> debbugs.gnu.org" <78660 <at> debbugs.gnu.org>
Subject: Re: bug#78660: [PATCH] Add context menu for commenting in prog-mode
Date: Wed, 04 Jun 2025 20:41:32 +0300
>> While there are a wide range of commands, I think only the common ones
>> should be added to the context menu. I don't think stuffing context
>> menus with all possible commands is a good choice, this will cause
>> users end up finding commands in submenus.
>
> Or like there is for example 'treesit-font-lock-level' that defines
> how much fontification the user wants, we could add an option that
> defines how many menu items the user wants to add to the context menu.

Actually there are already commenting-related menu items
in many mode menus, for example, in emacs-lisp-mode:

  Emacs Lisp -> Comment Out Region

in c-mode:

  C -> Comment Out Region
       Uncomment Region
       Fill Comment Paragraph

However, they are inconsistent and vary from mode to mode.
So maybe a new option like 'context-menu-items'
could support a set of symbols, where a possible symbol for
mode-independent comment-related menu items could be 'comment'.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78660; Package emacs. (Fri, 06 Jun 2025 07:57:02 GMT) Full text and rfc822 format available.

Message #20 received at 78660 <at> debbugs.gnu.org (full text, mbox):

From: Billy Lei <LeiYiXia29 <at> outlook.com>
To: Juri Linkov <juri <at> linkov.net>
Cc: "78660 <at> debbugs.gnu.org" <78660 <at> debbugs.gnu.org>
Subject: Re: bug#78660: [PATCH] Add context menu for commenting in prog-mode
Date: Fri, 6 Jun 2025 15:56:42 +0800
IMO the current way of implementing context menus are not readable 
enough. I've looked the source code of functions like prog-context-menu, 
dired-context-menu, they tends to use `when` to control whether a menu 
is visible, which is more complex. I think we should use :visible to 
replace them to make them more readable.

By the way, before context menu is implemented, users can already see 
the menu bar items by right-click, so IMO displaying all the commands 
should have implemented (if the menu bar has all the commands).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78660; Package emacs. (Fri, 06 Jun 2025 15:51:02 GMT) Full text and rfc822 format available.

Message #23 received at 78660 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Billy Lei <LeiYiXia29 <at> outlook.com>
Cc: "78660 <at> debbugs.gnu.org" <78660 <at> debbugs.gnu.org>
Subject: Re: bug#78660: [PATCH] Add context menu for commenting in prog-mode
Date: Fri, 06 Jun 2025 18:40:19 +0300
> IMO the current way of implementing context menus are not readable
> enough. I've looked the source code of functions like prog-context-menu,
> dired-context-menu, they tends to use `when` to control whether a menu is
> visible, which is more complex. I think we should use :visible to replace
> them to make them more readable.

There is no need to use :visible when context menus are constructed
dynamically on every mouse click since the menu content depends on
context including text properties that define the context functions.

> By the way, before context menu is implemented, users can already see the
> menu bar items by right-click, so IMO displaying all the commands should
> have implemented (if the menu bar has all the commands).

These menus already can be included to the context menu as submenus.




This bug report was last modified today.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.