GNU bug report logs -
#53910
29.0.50; context-menu-mode breaks help in read-only buffers
Previous Next
Reported by: Ergus <spacibba <at> aol.com>
Date: Thu, 10 Feb 2022 00:17:01 UTC
Severity: normal
Tags: confirmed
Fixed in version 29.0.50
Done: Juri Linkov <juri <at> linkov.net>
Bug is archived. No further changes may be made.
Full log
Message #36 received at 53910 <at> debbugs.gnu.org (full text, mbox):
>> > 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
...)
This bug report was last modified 3 years and 149 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.