From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail
From: Thierry Volpiatto <thievol@posteo.net>
Newsgroups: gmane.emacs.bugs
Subject: bug#66394: 29.1; Make register-read-with-preview more useful
Date: Mon, 18 Dec 2023 05:15:09 +0000
Message-ID: <87h6kghz1e.fsf@posteo.net>
References: <87il7ib6cu.fsf@posteo.net> <83jzpkvs4z.fsf@gnu.org>
 <87v8947ulo.fsf@posteo.net> <871qbsk5le.fsf@posteo.net>
 <f7f749d1-3a2d-0ea0-a106-6c586f4faca7@gutov.dev>
 <87v894hr2e.fsf@posteo.net> <87cyvbepi0.fsf@posteo.net>
 <87bkavk9nv.fsf@posteo.net>
 <8eebbb30-9366-e869-a39a-8100638cb99a@gutov.dev>
 <87o7etgxeb.fsf@posteo.net> <83v891qlcn.fsf@gnu.org>
 <jwvfs04hjm9.fsf-monnier+emacs@gnu.org>
 <CADwFkmm3H9+-nrYi0JQM9YT0_ZYU3SYvcqfmEnEpJWWaZzHTGQ@mail.gmail.com>
 <87r0jn4j8i.fsf@posteo.net> <jwv8r5vfqo6.fsf-monnier+emacs@gnu.org>
 <87jzpf48k5.fsf@posteo.net> <jwvplz73vpg.fsf-monnier+emacs@gnu.org>
 <87plz6xp3m.fsf@posteo.net> <jwvzfya2mk9.fsf-monnier+emacs@gnu.org>
 <87sf41ubjj.fsf@posteo.net> <jwv34w0e807.fsf-monnier+emacs@gnu.org>
Mime-Version: 1.0
Content-Type: multipart/signed; boundary="=-=-=";
 micalg=pgp-sha512; protocol="application/pgp-signature"
Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214";
	logging-data="17992"; mail-complaints-to="usenet@ciao.gmane.io"
Cc: michael_heerdegen@web.de, dmitry@gutov.dev, Eli Zaretskii <eliz@gnu.org>,
 Stefan Kangas <stefankangas@gmail.com>, 66394@debbugs.gnu.org
To: Stefan Monnier <monnier@iro.umontreal.ca>
Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 18 06:17:06 2023
Return-path: <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>
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 <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org>)
	id 1rF600-0004RN-HO
	for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 18 Dec 2023 06:17:04 +0100
Original-Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <bug-gnu-emacs-bounces@gnu.org>)
	id 1rF5z0-00074H-DG; Mon, 18 Dec 2023 00:16:02 -0500
Original-Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1rF5yz-000742-BR
 for bug-gnu-emacs@gnu.org; Mon, 18 Dec 2023 00:16:01 -0500
Original-Received: from debbugs.gnu.org ([2001:470:142:5::43])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
 id 1rF5yz-0003Mr-1H
 for bug-gnu-emacs@gnu.org; Mon, 18 Dec 2023 00:16:01 -0500
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1rF5z0-0007te-CL
 for bug-gnu-emacs@gnu.org; Mon, 18 Dec 2023 00:16:02 -0500
X-Loop: help-debbugs@gnu.org
Resent-From: Thierry Volpiatto <thievol@posteo.net>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@gnu.org
Resent-Date: Mon, 18 Dec 2023 05:16:02 +0000
Resent-Message-ID: <handler.66394.B66394.170287652926343@debbugs.gnu.org>
Resent-Sender: help-debbugs@gnu.org
X-GNU-PR-Message: followup 66394
X-GNU-PR-Package: emacs
Original-Received: via spool by 66394-submit@debbugs.gnu.org id=B66394.170287652926343
 (code B ref 66394); Mon, 18 Dec 2023 05:16:02 +0000
Original-Received: (at 66394) by debbugs.gnu.org; 18 Dec 2023 05:15:29 +0000
Original-Received: from localhost ([127.0.0.1]:59299 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1rF5yT-0006pQ-8U
 for submit@debbugs.gnu.org; Mon, 18 Dec 2023 00:15:29 -0500
Original-Received: from mout02.posteo.de ([185.67.36.66]:34345)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <thievol@posteo.net>) id 1rF5yO-0006LV-3w
 for 66394@debbugs.gnu.org; Mon, 18 Dec 2023 00:15:28 -0500
Original-Received: from submission (posteo.de [185.67.36.169]) 
 by mout02.posteo.de (Postfix) with ESMTPS id 9DCC4240103
 for <66394@debbugs.gnu.org>; Mon, 18 Dec 2023 06:15:15 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1702876515; bh=yNF7mgqRF7sc/DB4VKABCbxEWJowuJfcqCYGF6gEHoc=;
 h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Autocrypt:OpenPGP:
 From;
 b=fNAzwwl6xZ73QxaEhqoq5pdSjN21gtRe73XY6iZGKjKiOJ7TtHs5WIya/+t3my6Ul
 Br5bg4ynWPjV8/z4toF+QwSVm7BTsrUy7VkYmOhHVhsS0cgumOc5aliD2DqMRnmFF2
 pKqZm7Pa2zzgDy+eYo/EBv+LzBNCnc1BRLPfF+vboUI5z4gcJl5FuKl3oMum+EVrJi
 odx8vWOZhfvgCoS4164qQiToknCUVliOswYlSN8NZQHr4v42kKjP9QO1JObk7zbGK+
 AXo5fGG7WtfFrP2CXovZ4P18o7/EfbRJxo07FDnhA1v1ypzcMfNd/9+LcUWEl4DeNf
 Ug3BwIkYjaGTw==
Original-Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4Stp1D5g1Sz6tm4;
 Mon, 18 Dec 2023 06:15:12 +0100 (CET)
In-Reply-To: <jwv34w0e807.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message
 of "Sun, 17 Dec 2023 18:20:56 -0500 (5 hours, 33 minutes,
 34 seconds ago)")
Autocrypt: addr=thievol@posteo.net; prefer-encrypt=mutual;
 keydata=xsDNBF8ylcIBDADG+hy+zR6L4/vbdDDZuSaMmSrU3A5QZJpeBCvxTr7MpzzruZbhLPW1K3R6N2MA
 edi8Y+C8o27FVRIjpdbaKMGu9je7JV/TbUQYo3SOwCK1vM4LUn4V6ZLzSYkuiEt4eyMoiDdyvN0p
 kcK6P9x9DCetcEVszXzQg+yzCVrQ2hXWDXWT4M18EC3wtO7RHPouMqGiwBFhBAYErCqFWFxQHkfb
 tG/4yGyJ58rglb65O3qijjMWvYwcWZun9/7qm8Z4/4mHopmo2zgU+OrptnLSZfkZGz3Y7Uf452xQ
 GVq0Fv75NPvQru7y+DYVhuVXXyAmGxt+vf4rIiixMBbhKEPjcxEPAa2LTzex2IsTZR+QVG9uDnqC
 WcgaOEQ58fzXNvNhtwwF/Rgio2XWAJVdmFWS59/k9W58CIUSNKBMZh2XeGdEmtHvDtCxW3z6FJha
 36RzOM3fMNNiAGdFZJA84gcdloJR+sHCDTTPT3784fjr+V8An7sI581NGFzkRQqPvEQCZbUAEQEA
 Ac0SdGhpZXZvbEBwb3N0ZW8ubmV0wsEOBBMBCgA4AhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheA
 FiEEI9twfRN7r3nig/xwDsVtFB0W75MFAmL3HCoACgkQDsVtFB0W75OVEAv/f6XxmtIFz08fUb8h
 Bp/zJP6IC4/rhhh+0GMRIRzLN8DK0jV8JCzYdFHiRJOy2lNIOpmrrCmjRRxferc2G42+ePFIsslx
 hU46VSz1Z83NwIG3mpdYNV5WUTUdgzxExHTNTFCd7NKv0nlHKQaA 
OpenPGP: url=https://posteo.de/keys/thievol@posteo.net.asc; preference=encrypt
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" <bug-gnu-emacs.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-gnu-emacs>,
 <mailto:bug-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/bug-gnu-emacs>
List-Post: <mailto:bug-gnu-emacs@gnu.org>
List-Help: <mailto:bug-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-gnu-emacs>,
 <mailto:bug-gnu-emacs-request@gnu.org?subject=subscribe>
Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org
Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org
Xref: news.gmane.io gmane.emacs.bugs:276452
Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/276452>

--=-=-=
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> From 6a15a8b7b795b8377ef3537dc7bbd5ba26c0e159 Mon Sep 17 00:00:00 2001
>> From: Thierry Volpiatto <thievol@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) ?
=20
=2D-=20
Thierry

--=-=-=
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQHHBAEBCgAxFiEEI9twfRN7r3nig/xwDsVtFB0W75MFAmV/1V0THHRoaWV2b2xA
cG9zdGVvLm5ldAAKCRAOxW0UHRbvk15cC/9zeCq6VHxkrPK8YWVLhkLWOE8OF9z6
ZEiMzeyeOQe2h97aA/+zVGEB4jAU18N3xUdVf5eiC3Q2hoS09kG32gS/To2coRRD
UXcKZ4htchYf0yzzJlsGeNI4Y+UjFmoEVD8T2oXEIUfOQ1X5yK36YSWSCMMsmMQb
hf+XmGj/3ZwuG5zrRJzUBi4+GERFeWFq+IwIZGXQJO0DrH3qGySUo8HxOQjrdRnS
/IzKuI6VENNseHfLCAdusiYhxbCHcgHDPwCq8Y4qLM8zOHW4gVGWdpRH+bjHLa3w
iF6DqEnbE+X63o0UTdMeBThu92HIzFOowkZV35LDFr25ybG+w4Gf0CsPwIOQhz76
HHZ4dNYaE0RRcxdvWKnUNzdlmWaXa5wsowe9vAVR1fWRKadzmhn/E3Cmq/OhoZCk
1At6mQy1NvZKW03tM7u63jEC07gy1hn6pBLD5i/0BD6Tu3B8kLK9ITVY7pR53Ycc
5GLnyQhZntrmGWV8wGCYl9tlNhnrgIAP0bI=
=HIKN
-----END PGP SIGNATURE-----
--=-=-=--