From: Juri Linkov <juri@linkov.net>
To: Drew Adams <drew.adams@oracle.com>
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: Sat, 12 Feb 2022 19:05:03 +0200 [thread overview]
Message-ID: <86pmns10kw.fsf@mail.linkov.net> (raw)
In-Reply-To: <SJ0PR10MB5488B00E10B27DEA37205830F3309@SJ0PR10MB5488.namprd10.prod.outlook.com> (Drew Adams's message of "Fri, 11 Feb 2022 16:46:43 +0000")
>> > But 'select-window' only does
>> >
>> > In addition, make WINDOW’s buffer current and set its
>> > buffer’s value of ‘point’ to the value of WINDOW’s ‘window-point’.
>> >
>> > as advertised. Or do you mean something else?
>>
>> Yep, this is what I meant. I expected it no-op
>> in this case, but the documented behavior is fine.
>
> Maybe it would help to draw some more attention
> to this in the doc somehow?
>
> I don't find this obvious at all, even if the doc
> does specify it. The function names don't give
> the impression that the behavior you speak of is
> part of the what the functions do.
I don't know, maybe the docstring could warn about this case too.
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.
This idiom is used to prevent duplicating body in e.g.:
(if window
(with-selected-window window
body
...)
;; Else call `body' in the selected window:
body
...)
To avoid this problem, maybe the macro `with-selected-window'
could select the window only if it is non-nil, like this:
diff --git a/lisp/subr.el b/lisp/subr.el
index a78af09c40..2e528f5c8c 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -4224,7 +4224,8 @@ with-selected-window
(internal--before-with-selected-window ,window)))
(save-current-buffer
(unwind-protect
- (progn (select-window (car save-selected-window--state) 'norecord)
+ (progn (when (car save-selected-window--state)
+ (select-window (car save-selected-window--state) 'norecord))
,@body)
(internal--after-with-selected-window save-selected-window--state)))))
Then this could be used even when 'window' is nil:
(with-selected-window window
body
...)
next prev parent reply other threads:[~2022-02-12 17:05 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 [this message]
2022-02-13 8:49 ` martin rudalics
2022-02-13 18:50 ` Juri Linkov
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=86pmns10kw.fsf@mail.linkov.net \
--to=juri@linkov.net \
--cc=53910@debbugs.gnu.org \
--cc=drew.adams@oracle.com \
--cc=larsi@gnus.org \
--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).