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: Sat, 16 Dec 2023 13:18:37 +0000 Message-ID: <87plz6xp3m.fsf@posteo.net> References: <87il7ib6cu.fsf@posteo.net> <83v89j6arv.fsf@gnu.org> <87cyvpf8y6.fsf@posteo.net> <83plzp82mb.fsf@gnu.org> <87a5qhxf05.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> 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="34268"; 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 Sat Dec 16 14:19:21 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 1rEUZc-0008fH-Bb for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 16 Dec 2023 14:19:20 +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 1rEUZQ-0002nr-IV; Sat, 16 Dec 2023 08:19:08 -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 1rEUZK-0002ms-Ir for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2023 08:19:02 -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 1rEUZJ-00048A-Gm for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2023 08:19:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1rEUZJ-0004hK-Px for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2023 08:19: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: Sat, 16 Dec 2023 13:19:01 +0000 Resent-Message-ID: <handler.66394.B66394.170273273718046@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.170273273718046 (code B ref 66394); Sat, 16 Dec 2023 13:19:01 +0000 Original-Received: (at 66394) by debbugs.gnu.org; 16 Dec 2023 13:18:57 +0000 Original-Received: from localhost ([127.0.0.1]:54222 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>) id 1rEUZF-0004gz-26 for submit@debbugs.gnu.org; Sat, 16 Dec 2023 08:18:57 -0500 Original-Received: from mout01.posteo.de ([185.67.36.65]:50969) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <thievol@posteo.net>) id 1rEUZA-0004gd-Ok for 66394@debbugs.gnu.org; Sat, 16 Dec 2023 08:18:55 -0500 Original-Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 781B224002B for <66394@debbugs.gnu.org>; Sat, 16 Dec 2023 14:18:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1702732725; bh=ZwWhlMp4215rw3K/ZOsEbfUWHppKBlxyOZNF9nYcIwg=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Autocrypt:OpenPGP: From; b=SUQcIERbO/qzUA9z38E5ej5RL/8lQHvbQIYlb7tlrHSg4ZxECxBcuUbARm5w/VM7Q Q4O4XXywVNjX/BqbDHAPZPv3eo24b/rez9APKHcQoWLraFPSsbLvS36R0GYtRDLVTc 0/QMm76cdiVsxA+1wjFySg02V4QUquE83UUJuikDuEtzcNPICehxGpN4wMyoyLF74a ijkA9CjjV7J4MTdVd39gpsOHn161wH6h1p4k5JCYYr4Yo7QJyRk/nn/i3JBwDNs1v1 CREX+ZuImFmdxMze+vXaHgSWdntnQCeEbTc4gyjBvroR98KSDXXo/gOnA3P3tUM7lC TRemGdeR56H3A== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Ssmr22D12z6tmv; Sat, 16 Dec 2023 14:18:41 +0100 (CET) In-Reply-To: <jwvplz73vpg.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Fri, 15 Dec 2023 18:30:56 -0500 (13 hours, 39 minutes, 21 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:276336 Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/276336> --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Stefan Monnier <monnier@iro.umontreal.ca> writes: >>> - Why did you change from using >>> `register--read-with-preview-function` to using >>> (default-value 'register--read-with-preview-function) ? >>> [ The answer should presumably be in the commit message but >>> I couldn't find it there. ] >>> >>> - Why let-bind `register--read-with-preview-function` >>> rather than using a local lexical var? >>> [ The answer should probably be in a comment in the code. ] >> >> To answer to your 1) and 2) questions, I guess what you >> suggest is something like this (indeed better): >> >> diff --git a/lisp/register.el b/lisp/register.el >> index 15ed5c0a53b..2444f88794e 100644 >> --- a/lisp/register.el >> +++ b/lisp/register.el >> @@ -429,12 +429,11 @@ Format of each entry is controlled by the vari= able `register-preview-function'." >> Prompt with the string PROMPT. >> If `help-char' (or a member of `help-event-list') is pressed, >> display such a window regardless." >> - (let ((register--read-with-preview-function >> - (if (and executing-kbd-macro >> - (memq register-use-preview '(nil never))) >> - #'register-read-with-preview-basic >> - (default-value 'register--read-with-preview-function)))) >> - (funcall register--read-with-preview-function prompt))) >> + (let ((fn (if (and executing-kbd-macro >> + (memq register-use-preview '(nil never))) >> + #'register-read-with-preview-basic >> + register--read-with-preview-function))) >> + (funcall fn prompt))) >>=20=20=20=20=20=20 >> (defun register-read-with-preview-basic (prompt) >> "Read and return a register name, possibly showing existing regis= ters. > > LGTM, thanks. > >>> - Making the behavior dependent on `executing-kbd-macro` is generally >>> undesirable, so it should be accompanied with a comment in the code >>> explaining why we need it (with enough detail that someone >>> sufficiently motivated could potentially "fix" the code to remove this >>> dependency, or alternatively to convince that someone else that this >>> dependency is actually desirable here). >> >> The explanation is in the commit message. > > Then please move it into a comment in the code. Done. >> To resume, when we are not >> using RET to exit minibuffer, we use `exit-minibuffer` from the timer >> function in minibuffer-setup-hook, BTW when you have a macro using >> e.g. "C-x r i, C-n, C-a, C-x r +", "C-n and C-a" are running >> immediately BEFORE the minibuffer is exited so they run in minibuffer >> and have no effect in your macro that run in current-buffer. >> Is such a comment sufficiently explicit? (will add in next patch if so). > > Sounds good, yes. > >> If you have a better fix for this I take ;-). > > I haven't looked enough at the code to have a better suggestion. > From what I see the only way to have a "better fix" would be to forego > the use of asynchronous code (i.e. of a timer). I don't know why you're > using a timer, but usually people don't use timer just because they're > pretty, so I assume you've considered other options already (such as > using an `after-change-function` or a `post-command-hook` instead of > a timer). It should be possible to use post-command-hook, I didn't use it because it makes harder the communication between the minibuffer and the preview buffer. > [ FWIW, I suspect we have a similar problem in `read-key`. > Maybe that's the reason why people refrain from using `read-key`? > I can't see any comment in `read-key` mentioning that it doesn't work > in kmacros, but indeed it uses a timer just like you do, so it > probably fails in the exact same way. ] > >> The problem with such a fix (as I did) is that we can't have an hybrid >> version of preview i.e. one that use RET to confirm overwrite and no RET >> for other things. >> For example if one add a configuration like below to modify behavior >> with *-use-preview =3D=3D nil the macro will fail to execute properly. > > You might want to add a short hint about that problem in the comment. Ok, will add this in next patch. >> Thanks Stefan for reviewing this. > > I looked only at the kmacro part (because I thought maybe it had to do > with kmacro's use of OClosures), sorry. Anyway your comments were useful, as always, thanks. =2D-=20 Thierry --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQHHBAEBCgAxFiEEI9twfRN7r3nig/xwDsVtFB0W75MFAmV9o60THHRoaWV2b2xA cG9zdGVvLm5ldAAKCRAOxW0UHRbvkweXDAC3keSTLTzWEb4BSJ7wcp29mIZ45k0V XDjvmeXJNXjiBtuUwz0U7crdm7JiP+iqDX4//gupxA1mG8s8igOP0EsAlqsUs/s3 PzIiB6gq81vKmP82Dtxqh/Z2B7iZo7dfkiIaoKYSAzeIkynfBI+iLO5ZzzIa3J/q 2e8iSXS9anGmDUTGvBegcGOeqnoL2k9EQIBT5ASr+pJbThdgK4utR+UBKB/1zE0G e22o1ztChmaocgj4Of272FcJeOljmqGEii5r2nDj+tR2MIcDW4vcM38wNqw02QJL l9xq6Dblzsg6fTpfmDQqD6pQM/n4mqg8rz9oBZv1WqAJXpqo9qrrE7HjSnaakFbi WS8oDmUT2DvrNpLsulpj3nq9gI+l/yFGoWXToe/56dyKyifPW7ixBk4Fu8sALEtV 4BavPJGE7kKltSUGKTsV6zwl1MPMffznXJZXTwMz9s+Qo0hzELA3qJnUnr44HJTT 00ZvQ/W0I42rAOx1wptQ+otbDXLNGtKOiEU= =NQ/J -----END PGP SIGNATURE----- --=-=-=--