From: Jim Porter <jporterbugs@gmail.com>
To: 52237@debbugs.gnu.org
Subject: bug#52237: 29.0.50; [PATCH] Doubled separators in context-menu-mode
Date: Wed, 1 Dec 2021 22:06:13 -0800 [thread overview]
Message-ID: <0bbe5580-8e05-4e18-5b91-04b41b6f19bc@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1394 bytes --]
Sometimes, menu separators are doubled up in context-menu-mode. To see
this in action:
emacs -Q --eval '(context-menu-mode)'
;; Right-click somewhere in the scratch buffer, like the empty area.
You should see a double separator just before "Lisp-Interaction".
`context-menu-map' tries to eliminate doubled separators, but it doesn't
account for *tripled* separators. If we have a menu like so ("->" is the
current list item when iterating):
-> (separator-foo "--")
(separator-bar "--")
(separator-baz "--")
(regular-item "Item")
The duplicate remover sees that both the current item and the next are
separators, so removes it:
-> (separator-foo "--")
(separator-baz "--")
(regular-item "Item")
But then the very next operation is to move to the next list item:
(separator-foo "--")
-> (separator-baz "--")
(regular-item "Item")
Now, on the next iteration of the while loop, it won't detect the
duplicate because it's too far ahead. Attached is a patch to fix this;
it only advances to the next list item when it *didn't* just delete a
duplicate separator. That way, it can keep deleting subsequent dupes
until it sees a non-separator item.
I've only tested this on Emacs 29 so far, but it may occur on Emacs 28
as well. Also, I noticed that separators can appear at the beginning
and/or end of the context menu. Should they be removed too?
[-- Attachment #2: 0001-Ensure-there-are-no-duplicate-separators-when-creati.patch --]
[-- Type: text/plain, Size: 1255 bytes --]
From b5983b920eba32fa944758f510cb5fee6c281d4b Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Wed, 1 Dec 2021 21:55:31 -0800
Subject: [PATCH] Ensure there are no duplicate separators when creating a
context menu
Previously, if there were three or more consecutive menu separators,
not all of them would be removed.
* lisp/mouse.el (context-menu-map): Ensure no duplicate separators.
---
lisp/mouse.el | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lisp/mouse.el b/lisp/mouse.el
index 3ab9fbcdfe..ec43aecdd0 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -330,10 +330,10 @@ context-menu-map
;; Remove duplicate separators
(let ((l menu))
(while (consp l)
- (when (and (equal (cdr-safe (car l)) menu-bar-separator)
- (equal (cdr-safe (cadr l)) menu-bar-separator))
- (setcdr l (cddr l)))
- (setq l (cdr l))))
+ (if (and (equal (cdr-safe (car l)) menu-bar-separator)
+ (equal (cdr-safe (cadr l)) menu-bar-separator))
+ (setcdr l (cddr l))
+ (setq l (cdr l)))))
(when (functionp context-menu-filter-function)
(setq menu (funcall context-menu-filter-function menu click)))
--
2.25.1
next reply other threads:[~2021-12-02 6:06 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-02 6:06 Jim Porter [this message]
2021-12-02 8:24 ` bug#52237: 29.0.50; [PATCH] Doubled separators in context-menu-mode Lars Ingebrigtsen
2021-12-02 17:44 ` Juri Linkov
2021-12-03 4:46 ` bug#52237: 29.0.50; [PATCH 2] " Jim Porter
2021-12-03 16:10 ` Lars Ingebrigtsen
2021-12-05 9:32 ` Juri Linkov
2021-12-05 20:20 ` Lars Ingebrigtsen
2021-12-03 16:08 ` bug#52237: 29.0.50; [PATCH] " Lars Ingebrigtsen
2021-12-04 6:44 ` Jim Porter
2021-12-04 8:26 ` Eli Zaretskii
2021-12-02 17:31 ` bug#52237: [External] : " Drew Adams
2021-12-02 18:09 ` Jim Porter
2021-12-02 18:25 ` bug#52237: [External] : " Drew Adams
2021-12-02 18:47 ` Jim Porter
2021-12-04 19:50 ` Juri Linkov
2021-12-04 20:56 ` Jim Porter
2021-12-04 22:09 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0bbe5580-8e05-4e18-5b91-04b41b6f19bc@gmail.com \
--to=jporterbugs@gmail.com \
--cc=52237@debbugs.gnu.org \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.