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: 29.0.50; [PATCH] Prevent further cases of duplicated separators in context menus Date: Mon, 06 Dec 2021 11:23:59 +0200 Organization: LINKOV.NET Message-ID: <86pmqa14fc.fsf@mail.linkov.net> References: <86tufn5jn9.fsf@mail.linkov.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10097"; 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 To: Jim Porter Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 06 10:40:29 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 1muAU0-0002Ht-QB for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 06 Dec 2021 10:40:28 +0100 Original-Received: from localhost ([::1]:56200 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muATy-0001R5-Sz for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 06 Dec 2021 04:40:26 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:58258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muATb-0001Qc-83 for bug-gnu-emacs@gnu.org; Mon, 06 Dec 2021 04:40:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:49016) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1muATa-0008WE-W5 for bug-gnu-emacs@gnu.org; Mon, 06 Dec 2021 04:40:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1muATa-00069F-UD for bug-gnu-emacs@gnu.org; Mon, 06 Dec 2021 04:40: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, 06 Dec 2021 09:40: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.163878357923525 (code B ref 52293); Mon, 06 Dec 2021 09:40:02 +0000 Original-Received: (at 52293) by debbugs.gnu.org; 6 Dec 2021 09:39:39 +0000 Original-Received: from localhost ([127.0.0.1]:60548 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1muATC-00067N-Tr for submit@debbugs.gnu.org; Mon, 06 Dec 2021 04:39:39 -0500 Original-Received: from relay11.mail.gandi.net ([217.70.178.231]:35405) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1muATB-000674-Bs for 52293@debbugs.gnu.org; Mon, 06 Dec 2021 04:39:38 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by relay11.mail.gandi.net (Postfix) with ESMTPSA id B4AF810000B; Mon, 6 Dec 2021 09:39:29 +0000 (UTC) In-Reply-To: (Jim Porter's message of "Sun, 5 Dec 2021 20:50:32 -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:221733 Archived-At: > On 12/5/2021 9:59 AM, Juri Linkov wrote: >>> (defun help-mode-context-menu (menu click) >>> "Populate MENU with Help mode commands at CLICK." >>> - (define-key menu [help-mode-separator] menu-bar-separator) >>> + (define-key-after menu [help-mode-separator] menu-bar-separator >>> + 'top-separator) >> Now I realized that it's possible to do the same without 'top-separator': >> (define-key-after menu [help-mode-separator] menu-bar-separator >> "Context Menu") >> Or when the title string is defined as a variable: >> (defvar context-menu-title "Context Menu") >> (define-key-after menu [help-mode-separator] menu-bar-separator >> context-menu-title) >> But maybe 'top-separator' still could be used for clarity? >> Or it increases complexity? > > Hmm, that might work. One downside is that I think it makes it harder for > context menu functions to change the menu's title/prompt to something > else. Of course, if we used `context-menu-title' as the anchor like your > example above, it should still be possible to update the menu title via > `context-menu-filter-function'. That would be trickier to use though, at > least in the situations I have in mind. I agree that relying on the constant value of the menu title would be too unreliable. > For example, I added a very limited context menu that uses the menu title > in my config under Emacs 27 for org-mode links: I can right-click and it > shows a context menu with the URL as the title and menu items for different > ways to open the URL (in Firefox, Firefox Private Browsing, or EWW). It's > nice to be able to see the URL since that can influence which item > I choose. Good example. Another example is flyspell that shows a misspelled word in the menu title. > Updating this part of my config for Emacs 28 was actually what prompted me > to start looking into `context-menu-mode' in more detail. It would be > easier to implement this if context menu functions didn't rely on the > context menu title having a particular value. I think the remaining problem we have to solve is to try to prevent such a situation when the user accidentally removes `context-menu-top-separator' from `context-menu-functions'. To not break the menu in this case, maybe we need to ensure that the menu always contains `top-separator' as well as `middle-separator' even when `context-menu-functions' doesn't contain a function that adds them? I.e. just to check if these separators are missing, and add them at the top.