GNU bug report logs - #66394
29.1; Make register-read-with-preview more useful

Previous Next

Package: emacs;

Reported by: Thierry Volpiatto <thievol <at> posteo.net>

Date: Sat, 7 Oct 2023 19:07:01 UTC

Severity: normal

Found in version 29.1

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Thierry Volpiatto <thievol <at> posteo.net>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: michael_heerdegen <at> web.de, dmitry <at> gutov.dev, Eli Zaretskii <eliz <at> gnu.org>, Stefan Kangas <stefankangas <at> gmail.com>, 66394 <at> debbugs.gnu.org
Subject: bug#66394: 29.1; Make register-read-with-preview more useful
Date: Mon, 18 Dec 2023 05:15:09 +0000
[Message part 1 (text/plain, inline)]
Stefan Monnier <monnier <at> iro.umontreal.ca> writes:

>> From 6a15a8b7b795b8377ef3537dc7bbd5ba26c0e159 Mon Sep 17 00:00:00 2001
>> From: Thierry Volpiatto <thievol <at> posteo.net>
>> Date: Thu, 14 Dec 2023 16:23:26 +0100
>> Subject: [PATCH 3/4] Save and restore win confs after register commands
>>
>> When several windows are open, the register preview may eat other
>> windows and break the current window configuration.
>>
>> * lisp/register.el (register-read-with-preview-fancy): Do it.
>> ---
>>  lisp/register.el | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/lisp/register.el b/lisp/register.el
>> index 8f0c6a7105d..1fadbe81056 100644
>> --- a/lisp/register.el
>> +++ b/lisp/register.el
>> @@ -473,6 +473,7 @@ display such a window regardless."
>>           (buffer1 "*Register quick preview*")
>>           (buf (if register-use-preview buffer buffer1))
>>           (pat "")
>> +         (winconf (current-window-configuration))
>>           (map (let ((m (make-sparse-keymap)))
>>                  (set-keymap-parent m minibuffer-local-map)
>>                  m))
>> @@ -573,6 +574,7 @@ display such a window regardless."
>>                        nil "No register specified")
>>             (string-to-char result))
>>        (when timer (cancel-timer timer))
>> +      (set-window-configuration winconf)
>>        (let ((w (get-buffer-window buf)))
>>          (and (window-live-p w) (delete-window w)))
>>        (and (get-buffer buf) (kill-buffer buf)))))
>
> While save&restore of window configuration often works well, it
> misbehaves in various cases (such as when the buffer is displayed in
> another frame, which case case `set-window-configuration` will do you
> no good).

Yes, I thought this would be enough, but no, there is as well another
problem in register-preview and register-preview-1 with this code which
is as well not working well if there is multiple windows.

      (with-current-buffer-window
        buffer
        (cons 'display-buffer-below-selected
	      '((window-height . fit-window-to-buffer)
	        (preserve-size . (nil . t))))

[...]

At least it should use display-buffer-at-bottom, but I guess the best
would be to make this configurable in one way or the other.

>
> The official way to undo a `display-buffer` is with
> `quit-(restore-)window`.  See (info "(elisp)Quitting Windows").

Yes, this is not what the current code is using, see the last unwind
form of register-read-with-preview-basic/fancy.

But as Dmitri said, it is not bugs introduced by these patches, I
thought it would be simple to fix while we were at it but no.  I guess I
will follow Dmitri advice and not fix this in this serie of patches.
Perhaps we could make another bug report once these patches are applied
(I will remove the patch doing save/restore win conf) ?
 
-- 
Thierry
[signature.asc (application/pgp-signature, inline)]

This bug report was last modified 1 year and 210 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.