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#53910: [External] : bug#53910: 29.0.50; context-menu-mode breaks help in read-only buffers Date: Sun, 13 Feb 2022 20:50:10 +0200 Organization: LINKOV.NET Message-ID: <861r06vbos.fsf@mail.linkov.net> References: <20220210001600.vjiuqzoiuuzzj54c.ref@Ergus> <20220210001600.vjiuqzoiuuzzj54c@Ergus> <87mtizdwrv.fsf@gnus.org> <86y22jxfsq.fsf@mail.linkov.net> <87o83f7y3x.fsf@gnus.org> <86iltmpn0a.fsf@mail.linkov.net> <86wni13ifi.fsf@mail.linkov.net> <86pmns10kw.fsf@mail.linkov.net> <5d2c2af9-d011-583b-e9c1-985bbc2378c2@gmx.at> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37815"; 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: Lars Ingebrigtsen , Ergus , "53910@debbugs.gnu.org" <53910@debbugs.gnu.org> To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 13 19:57:13 2022 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 1nJK3c-0009hK-P7 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 13 Feb 2022 19:57:12 +0100 Original-Received: from localhost ([::1]:33660 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nJK3b-0004Up-49 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 13 Feb 2022 13:57:11 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:40980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nJK3S-0004Ud-1D for bug-gnu-emacs@gnu.org; Sun, 13 Feb 2022 13:57:04 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44990) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nJK3R-000718-OE for bug-gnu-emacs@gnu.org; Sun, 13 Feb 2022 13:57:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nJK3R-0007CL-OO for bug-gnu-emacs@gnu.org; Sun, 13 Feb 2022 13:57:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 13 Feb 2022 18:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53910 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: confirmed Original-Received: via spool by 53910-submit@debbugs.gnu.org id=B53910.164477860927651 (code B ref 53910); Sun, 13 Feb 2022 18:57:01 +0000 Original-Received: (at 53910) by debbugs.gnu.org; 13 Feb 2022 18:56:49 +0000 Original-Received: from localhost ([127.0.0.1]:38887 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJK3F-0007Bv-0S for submit@debbugs.gnu.org; Sun, 13 Feb 2022 13:56:49 -0500 Original-Received: from relay9-d.mail.gandi.net ([217.70.183.199]:49577) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nJK3B-0007Bf-Mb for 53910@debbugs.gnu.org; Sun, 13 Feb 2022 13:56:47 -0500 Original-Received: (Authenticated sender: juri@linkov.net) by mail.gandi.net (Postfix) with ESMTPSA id 371C1FF80B; Sun, 13 Feb 2022 18:56:36 +0000 (UTC) In-Reply-To: <5d2c2af9-d011-583b-e9c1-985bbc2378c2@gmx.at> (martin rudalics's message of "Sun, 13 Feb 2022 09:49:10 +0100") 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:226832 Archived-At: >> What worries me more is that the following idiom is not always safe: >> >> (with-selected-window (or window (selected-window)) >> body >> ...) >> >> because it might switch the buffer of the already selected window. > > IIUC you mean that it might make another buffer current? But the whole > idea of selecting a window is that it gets you in a consistent state > where, for example, the window is the selected window of its frame which > is also the selected frame and point returns the position of point of > the selected window. Everything else is of evil (on the Lisp level). Indeed, what describe-bindings does by calling context-menu after switching buffers is evil. Here is another attempt to prevent this: diff --git a/lisp/mouse.el b/lisp/mouse.el index 4c0d455808..1ad6fd089b 100644 --- a/lisp/mouse.el +++ b/lisp/mouse.el @@ -541,7 +541,9 @@ context-menu-ffap (defvar context-menu-entry `(menu-item ,(purecopy "Context Menu") ,(make-sparse-keymap) - :filter ,(lambda (_) (context-menu-map))) + :filter ,(lambda (_) (unless help-buffer-under-preparation + ;; No need to build menu to describe keys + (context-menu-map)))) "Menu item that creates the context menu and can be bound to a mouse key.") > I don't know why you need that idiom in tab-line.el but, for example, > the completely misguided > > (defun window-safely-shrinkable-p (&optional window) > "Return t if WINDOW can be shrunk without shrinking other windows. > WINDOW defaults to the selected window." > (with-selected-window (or window (selected-window)) > (let ((edges (window-edges))) > (or (= (nth 2 edges) (nth 2 (window-edges (previous-window)))) > (= (nth 0 edges) (nth 0 (window-edges (next-window)))))))) > > should be written as > > (defun window-safely-shrinkable-p (&optional window) > "Return t if WINDOW can be shrunk without shrinking other windows. > WINDOW defaults to the selected window." > (let ((edges (window-edges window))) > (or (= (nth 2 edges) (nth 2 (window-edges (previous-window window)))) > (= (nth 0 edges) (nth 0 (window-edges (next-window window))))))) > > So I'd urge you to rewrite the tab-line functions in a more safe way. While it's possible to use the 'window' argument in all functions used in window-safely-shrinkable-p, tab-line functions use functions that don't accept the 'window' argument, e.g. current-buffer, kill-buffer. But there is no problem for tab-line to select the already selected window since it operates on windows.