From: Juri Linkov <juri@linkov.net>
To: martin rudalics <rudalics@gmx.at>
Cc: Lars Ingebrigtsen <larsi@gnus.org>, Ergus <spacibba@aol.com>,
"53910@debbugs.gnu.org" <53910@debbugs.gnu.org>
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 [thread overview]
Message-ID: <861r06vbos.fsf@mail.linkov.net> (raw)
In-Reply-To: <5d2c2af9-d011-583b-e9c1-985bbc2378c2@gmx.at> (martin rudalics's message of "Sun, 13 Feb 2022 09:49:10 +0100")
>> 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.
next prev parent reply other threads:[~2022-02-13 18:50 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220210001600.vjiuqzoiuuzzj54c.ref@Ergus>
2022-02-10 0:16 ` bug#53910: 29.0.50; context-menu-mode breaks help in read-only buffers Ergus via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-10 7:08 ` Lars Ingebrigtsen
2022-02-10 8:54 ` Juri Linkov
2022-02-10 11:35 ` Lars Ingebrigtsen
2022-02-10 18:58 ` Juri Linkov
2022-02-11 8:31 ` martin rudalics
2022-02-11 8:40 ` Juri Linkov
2022-02-11 16:46 ` bug#53910: [External] : " Drew Adams
2022-02-12 17:05 ` Juri Linkov
2022-02-13 8:49 ` martin rudalics
2022-02-13 18:50 ` Juri Linkov [this message]
2022-02-17 19:13 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-17 19:30 ` Juri Linkov
2022-02-17 20:12 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-18 7:44 ` Juri Linkov
2022-02-18 8:32 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-20 18:56 ` Juri Linkov
2022-02-19 9:41 ` martin rudalics
2022-02-19 12:26 ` Eli Zaretskii
2022-02-19 17:07 ` martin rudalics
2022-02-19 17:22 ` Eli Zaretskii
2022-02-20 9:16 ` martin rudalics
2022-02-20 18:44 ` Juri Linkov
2022-02-21 9:07 ` martin rudalics
2022-02-22 17:10 ` Juri Linkov
2022-02-23 9:29 ` martin rudalics
2022-02-19 14:38 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-20 9:14 ` martin rudalics
2022-02-20 14:42 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-10 8:26 ` martin rudalics
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=861r06vbos.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=53910@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=rudalics@gmx.at \
--cc=spacibba@aol.com \
/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).