From: Jim Porter <jporterbugs@gmail.com>
To: Juri Linkov <juri@linkov.net>, Lars Ingebrigtsen <larsi@gnus.org>
Cc: 52237@debbugs.gnu.org
Subject: bug#52237: 29.0.50; [PATCH 2] Doubled separators in context-menu-mode
Date: Thu, 2 Dec 2021 20:46:28 -0800 [thread overview]
Message-ID: <ea800e78-c137-ea02-f1e4-6dc67c668404@gmail.com> (raw)
In-Reply-To: <861r2u3num.fsf@mail.linkov.net>
[-- Attachment #1: Type: text/plain, Size: 910 bytes --]
On 12/2/2021 9:44 AM, Juri Linkov wrote:
>>> I've only tested this on Emacs 29 so far, but it may occur on Emacs 28
>>> as well.
>>
>> Thanks; applied to Emacs 29.
>
> Why not to Emacs 28?
I got a chance to check this under Emacs 28, and the bug exists there
too, so it'd be nice to backport.
>>> Also, I noticed that separators can appear at the beginning
>>> and/or end of the context menu. Should they be removed too?
>>
>> Hm... I think that might make sense, but I'm not sure. Anybody got an
>> opinion?
>
> Removing leading/trailing separators would be nice too.
Ok, here's a patch to do it. There might be a better way to do this, but
it should work reliably.
Note: this patch doesn't fix the duplicated separators in the help-mode
context menu. I haven't had time to look into the right way to fix that
yet (there may be other mode-specific context menu functions that have
this bug too).
[-- Attachment #2: 0001-Remove-separators-at-the-beginning-and-end-of-the-co.patch --]
[-- Type: text/plain, Size: 1745 bytes --]
From c76d753b46199da04863f19f75faf100d8e9e773 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Thu, 2 Dec 2021 20:39:33 -0800
Subject: [PATCH] Remove separators at the beginning and end of the context
menu
* lisp/mouse.el (context-menu-map): Remove beginning/end seperators.
---
lisp/mouse.el | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/lisp/mouse.el b/lisp/mouse.el
index ec43aecdd0..b5ca80a446 100644
--- a/lisp/mouse.el
+++ b/lisp/mouse.el
@@ -327,12 +327,21 @@ context-menu-map
(setq menu (funcall fun menu click))
nil)))
- ;; Remove duplicate separators
- (let ((l menu))
- (while (consp l)
- (if (and (equal (cdr-safe (car l)) menu-bar-separator)
- (equal (cdr-safe (cadr l)) menu-bar-separator))
+ ;; Remove duplicate separators as well as ones at the beginning or
+ ;; end of the menu.
+ (let ((l menu) saw-first-item)
+ (while (consp (cdr l))
+ ;; If the next item is a separator, remove it if 1) we haven't
+ ;; seen any other items yet, or 2) it's followed by either
+ ;; another separator or the end of the list.
+ (if (and (equal (cdr-safe (cadr l)) menu-bar-separator)
+ (or (not saw-first-item)
+ (null (caddr l))
+ (equal (cdr-safe (caddr l)) menu-bar-separator)))
(setcdr l (cddr l))
+ ;; The "first item" is any cons cell; this excludes the
+ ;; `keymap' symbol and the menu name.
+ (when (consp (cadr l)) (setq saw-first-item t))
(setq l (cdr l)))))
(when (functionp context-menu-filter-function)
--
2.25.1
next prev parent reply other threads:[~2021-12-03 4:46 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-02 6:06 bug#52237: 29.0.50; [PATCH] Doubled separators in context-menu-mode Jim Porter
2021-12-02 8:24 ` Lars Ingebrigtsen
2021-12-02 17:44 ` Juri Linkov
2021-12-03 4:46 ` Jim Porter [this message]
2021-12-03 16:10 ` bug#52237: 29.0.50; [PATCH 2] " 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
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=ea800e78-c137-ea02-f1e4-6dc67c668404@gmail.com \
--to=jporterbugs@gmail.com \
--cc=52237@debbugs.gnu.org \
--cc=juri@linkov.net \
--cc=larsi@gnus.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 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).