unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Jim Porter <jporterbugs@gmail.com>
To: Drew Adams <drew.adams@oracle.com>, Eli Zaretskii <eliz@gnu.org>
Cc: "52293@debbugs.gnu.org" <52293@debbugs.gnu.org>,
	"juri@linkov.net" <juri@linkov.net>
Subject: bug#52293: [External] : bug#52293: 29.0.50; [PATCH v3] Prevent further cases of duplicated separators in context menus
Date: Sun, 12 Dec 2021 17:46:58 -0800	[thread overview]
Message-ID: <8e9b29cd-8700-1a60-1d91-b6995d8f433a@gmail.com> (raw)
In-Reply-To: <SJ0PR10MB54884CFC882358888FE9C3EBF3749@SJ0PR10MB5488.namprd10.prod.outlook.com>

On 12/12/2021 5:16 PM, Drew Adams wrote:
>>> 3. I think there's zero need for any naming
>>>      convention for menu-item names, whether
>>>      separators or other.
>>
>> The goal was to make it easier to remember the names of the separators
>> if you wanted to add a new item after a particular separator that had
>> already been added. It's easier to remember if they're all
>> `foo-separator' instead of a mix of styles.
> 
> Why does anyone need to _remember_ such names?
> What's the use case for remembering?

A third-party package author may want to insert context menu items in a 
particular spot in the menu (i.e. use `define-key-after'). Because the 
naming convention of separators is inconsistent, the author can more 
easily slip up and use the wrong name.

As you might be able to tell, this is a very small issue. But the fix 
was easy, so I posted a patch for it. I really don't have a problem with 
closing that bug as wontfix if it's controversial.

> Deduplication?  We're not talking about removing
> exact duplicates are we?  I thought this was about
> removing consecutive separators, leaving only one.
> This involves no duplicate menu items:
> 
>    (define-key menu [separator-1] '("--"))
>    (define-key menu [separator-2] '("--"))

That's correct. The above menu items would be de-duplicated since 
they're both separators. However, that logic only applies to "simple" 
separators, so the de-duplication code doesn't apply to this:

   (define-key menu [separator-1] '(menu-item "--"))
   (define-key menu [separator-2] '(menu-item "--"))

(It's possible that's just an accidental omission in the original code 
though.)

> More importantly, I didn't know this was about
> removing any ordinary `define-key' bindings.
> I really hope it's not.  I thought this was only
> for Juri's new context menus.

This is *only* for context menus. The de-duplication code is in 
`context-menu-map', which is a function that gets called when opening 
the context menu. It calls all the elements of `context-menu-functions' 
in order, and then does the de-duplication step. No other menus will be 
affected by this.

In any case, I think I prefer the solution I proposed in my followup: 
instead of removing consecutive separators so things look right, we can 
*add* separators between different "sections" of the context menu. 
Sections can be marked by the `:section' keyword and a name for the 
section (note: this only applies to the context menu, not other menus). 
That should completely prevent any unwanted manipulation of menus, since 
the programmer needs to opt into this behavior explicitly.

In my limited tests, that method is also less brittle than the current 
method (this bug is an example of the brittleness). See my other 
message[1] for more details.

[1] https://lists.gnu.org/archive/html/bug-gnu-emacs/2021-12/msg01079.html





  reply	other threads:[~2021-12-13  1:46 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-05  5:58 bug#52293: 29.0.50; [PATCH] Prevent further cases of duplicated separators in context menus Jim Porter
2021-12-05  9:39 ` Juri Linkov
2021-12-06  4:07   ` Jim Porter
2021-12-05 17:59 ` Juri Linkov
2021-12-06  4:50   ` Jim Porter
2021-12-06  9:23     ` Juri Linkov
2021-12-07  3:54       ` bug#52293: 29.0.50; [PATCH v2] " Jim Porter
2021-12-07  8:19         ` Juri Linkov
2021-12-08  4:37           ` bug#52293: 29.0.50; [PATCH v3] " Jim Porter
2021-12-08 12:59             ` Eli Zaretskii
2021-12-08 17:43               ` Jim Porter
2021-12-08 19:07               ` Juri Linkov
2021-12-08 19:47                 ` Eli Zaretskii
2021-12-09  9:06                   ` Juri Linkov
2021-12-09  9:39                     ` Eli Zaretskii
2021-12-12  4:02                       ` Jim Porter
2021-12-12  7:02                         ` Eli Zaretskii
2021-12-12 20:27                           ` Jim Porter
2021-12-12 20:43                             ` Eli Zaretskii
2021-12-12 21:59                               ` Jim Porter
2021-12-13 12:23                                 ` Eli Zaretskii
2021-12-13 18:13                                   ` Jim Porter
2021-12-12 21:00                             ` bug#52293: [External] : " Drew Adams
2021-12-12 22:12                               ` Jim Porter
2021-12-12 23:14                                 ` Jim Porter
2021-12-13  1:16                                 ` Drew Adams
2021-12-13  1:46                                   ` Jim Porter [this message]
2021-12-13  2:41                                     ` Drew Adams
2021-12-13  8:47                                     ` Juri Linkov
2021-12-13 17:25                                       ` Jim Porter
2021-12-13 18:58                                         ` Juri Linkov
2021-12-14  5:41                                           ` Jim Porter
2021-12-14  8:30                                             ` Juri Linkov
2021-12-14 13:04                                               ` Eli Zaretskii
2021-12-14 16:49                                                 ` Drew Adams
2021-12-14 20:51                                                   ` Juri Linkov
2021-12-14 22:02                                                     ` Drew Adams
2021-12-15  8:59                                                       ` Juri Linkov
2021-12-15 18:10                                                         ` Drew Adams
2021-12-15 18:24                                                           ` Juri Linkov
2021-12-15 21:36                                                             ` Drew Adams
2021-12-16 17:20                                                               ` Juri Linkov
2021-12-16 17:51                                                                 ` Drew Adams
2021-12-16 17:56                                                                   ` Drew Adams
2021-12-17  8:20                                                                   ` Juri Linkov
2021-12-17 17:21                                                                     ` Drew Adams
2021-12-15  0:17                                               ` Jim Porter
2021-12-15  8:57                                                 ` Juri Linkov
2022-01-01  7:13                                                   ` Jim Porter
2022-01-02 19:27                                                     ` Juri Linkov
2022-01-03  6:14                                                       ` bug#52293: 29.0.50; [PATCH v4] " Jim Porter
2022-01-04  8:19                                                         ` Juri Linkov
2022-01-04 21:14                                                           ` Jim Porter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8e9b29cd-8700-1a60-1d91-b6995d8f433a@gmail.com \
    --to=jporterbugs@gmail.com \
    --cc=52293@debbugs.gnu.org \
    --cc=drew.adams@oracle.com \
    --cc=eliz@gnu.org \
    --cc=juri@linkov.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).