From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#52293: [External] : bug#52293: 29.0.50; [PATCH v3] Prevent further cases of duplicated separators in context menus Date: Mon, 13 Dec 2021 10:47:22 +0200 Organization: LINKOV.NET Message-ID: <86czm0eue5.fsf@mail.linkov.net> References: <86tufn5jn9.fsf@mail.linkov.net> <86pmqa14fc.fsf@mail.linkov.net> <15eebcb1-b67a-8363-bc23-cf113913856f@gmail.com> <86h7bkhlo7.fsf@mail.linkov.net> <37047ada-fa33-88dd-5237-769611fec61b@gmail.com> <83wnkfw8ud.fsf@gnu.org> <86ilvysyq3.fsf@mail.linkov.net> <834k7ix4ij.fsf@gnu.org> <86pmq6taeb.fsf@mail.linkov.net> <83czm6unfs.fsf@gnu.org> <414be477-34d4-c777-f623-3e0e59c0dd08@gmail.com> <83o85mpaqb.fsf@gnu.org> <8e9b29cd-8700-1a60-1d91-b6995d8f433a@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="8691"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: "52293@debbugs.gnu.org" <52293@debbugs.gnu.org> To: Jim Porter Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 13 10:50:54 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mwhyw-00028h-1S for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 13 Dec 2021 10:50:54 +0100 Original-Received: from localhost ([::1]:59972 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mwhyv-00086r-2I for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 13 Dec 2021 04:50:53 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:54550) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mwhx9-0006p4-8j for bug-gnu-emacs@gnu.org; Mon, 13 Dec 2021 04:49:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42630) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mwhx9-0006M7-0Y for bug-gnu-emacs@gnu.org; Mon, 13 Dec 2021 04:49:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mwhx8-00007L-Ux for bug-gnu-emacs@gnu.org; Mon, 13 Dec 2021 04:49:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 13 Dec 2021 09:49:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52293 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 52293-submit@debbugs.gnu.org id=B52293.1639388897361 (code B ref 52293); Mon, 13 Dec 2021 09:49:02 +0000 Original-Received: (at 52293) by debbugs.gnu.org; 13 Dec 2021 09:48:17 +0000 Original-Received: from localhost ([127.0.0.1]:54168 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mwhwP-00005l-73 for submit@debbugs.gnu.org; Mon, 13 Dec 2021 04:48:17 -0500 Original-Received: from relay9-d.mail.gandi.net ([217.70.183.199]:47425) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mwhwM-00005I-Em for 52293@debbugs.gnu.org; Mon, 13 Dec 2021 04:48:15 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by relay9-d.mail.gandi.net (Postfix) with ESMTPSA id D9B7CFF812; Mon, 13 Dec 2021 09:48:06 +0000 (UTC) In-Reply-To: <8e9b29cd-8700-1a60-1d91-b6995d8f433a@gmail.com> (Jim Porter's message of "Sun, 12 Dec 2021 17:46:58 -0800") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:222298 Archived-At: >> 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.) Actually, this wasn't an omission. Now that I'm thinking more about this, maybe separators that are subject to possible removal could be marked by e.g. using text properties, thus opting into this behavior explicitly: (defconst context-menu-separator (list (propertize "--" 'remove t))) (define-key menu [separator-1] context-menu-separator) (define-key menu [separator-2] context-menu-separator) Then code that de-duplicates separators could check for this property. > 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. Adding a new keyword to every menu item requires more work from authors of context menus, and actually makes menus more brittle - when an author forgets to add the new keyword `:section' to some menu item, then two unexpected separators will be inserted: before and after such an item.