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: [RE] Make register-read-with-preview more useful Date: Sun, 08 Oct 2023 06:45:11 +0000 Message-ID: <874jj1obh2.fsf@posteo.net> References: <87il7ib6cu.fsf@posteo.net> 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="16786"; mail-complaints-to="usenet@ciao.gmane.io" To: 66394@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 08 08:50:19 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 1qpNcI-000479-OL for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 08 Oct 2023 08:50:18 +0200 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 1qpNbu-00010y-Ep; Sun, 08 Oct 2023 02:49:54 -0400 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 1qpNbo-00010a-Kf for bug-gnu-emacs@gnu.org; Sun, 08 Oct 2023 02:49:50 -0400 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 1qpNbi-0007nf-MZ for bug-gnu-emacs@gnu.org; Sun, 08 Oct 2023 02:49:48 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1qpNc2-0007m1-Am for bug-gnu-emacs@gnu.org; Sun, 08 Oct 2023 02:50:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87il7ib6cu.fsf@posteo.net> 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: Sun, 08 Oct 2023 06:50:02 +0000 Resent-Message-ID: <handler.66394.B66394.169674779129858@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.169674779129858 (code B ref 66394); Sun, 08 Oct 2023 06:50:02 +0000 Original-Received: (at 66394) by debbugs.gnu.org; 8 Oct 2023 06:49:51 +0000 Original-Received: from localhost ([127.0.0.1]:56172 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>) id 1qpNbq-0007lW-M5 for submit@debbugs.gnu.org; Sun, 08 Oct 2023 02:49:51 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:59067) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <thievol@posteo.net>) id 1qpNbn-0007lF-El for 66394@debbugs.gnu.org; Sun, 08 Oct 2023 02:49:48 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 2ADF0240101 for <66394@debbugs.gnu.org>; Sun, 8 Oct 2023 08:49:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1696747761; bh=pIcqiZUYPavDHCgdcEP+QFKdqtPgfmNpvvtjrcEIbCM=; h=From:To:Subject:Date:Message-ID:MIME-Version:Autocrypt:OpenPGP: From; b=rb8eyO6a7GwbEjbnfD2MVvDLDWjRKeBY5oJqcORLmtENV9MzFEBlCQ0B6rFjp5voh R0+WwjkgfXihmKxD6ebvO+a37hxB9VpUB1OvP6OhlLSICiBZx3o/9W3h/kvaRfY1sm i39ms2/g1EMqiuzBpCP7gUBTKkLU0ElM+kAZ6oVUNrLbCTU4sy8WAHWgVgUW/7e1T/ yRVQ5uB1lSFH8jEqPGtLGr3vS1QXr8wDA47RobOTaB2sVNR5sT2uHZDd9bDaaJ0Fjq +ncJD5DDj7OOkSfFW+0Gs89A2kF/SanJyFVIPC3Kpo8r7fu1K4cdAqoCUejvXvvChW 7YyUXK4v3OfLA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4S3CSc2pFbz9rxH for <66394@debbugs.gnu.org>; Sun, 8 Oct 2023 08:49:20 +0200 (CEST) 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:272061 Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/272061> --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable Here a modified version of the patch that fix the face, send an error when exiting with empty prompt and prevent adding more than one char in prompt. From=20this code, it is now easy to modify the behavior as needed (ideas we= lcome). diff --git a/lisp/register.el b/lisp/register.el index ca6de450993..47645098e6d 100644 =2D-- a/lisp/register.el +++ b/lisp/register.el @@ -154,27 +154,45 @@ listing existing registers after `register-preview-de= lay' seconds. If `help-char' (or a member of `help-event-list') is pressed, display such a window regardless." (let* ((buffer "*Register Preview*") =2D (timer (when (numberp register-preview-delay) =2D (run-with-timer register-preview-delay nil =2D (lambda () =2D (unless (get-buffer-window buffer) =2D (register-preview buffer)))))) =2D (help-chars (cl-loop for c in (cons help-char help-event-list) =2D when (not (get-register c)) =2D collect c))) + (pat "") + result timer) + (register-preview buffer) (unwind-protect =2D (progn =2D (while (memq (read-key (propertize prompt 'face 'minibuffer-prompt)) =2D help-chars) =2D (unless (get-buffer-window buffer) =2D (register-preview buffer 'show-empty))) =2D (when (or (eq ?\C-g last-input-event) =2D (eq 'escape last-input-event) =2D (eq ?\C-\[ last-input-event)) =2D (keyboard-quit)) =2D (if (characterp last-input-event) last-input-event =2D (error "Non-character input-event"))) =2D (and (timerp timer) (cancel-timer timer)) + (progn + (minibuffer-with-setup-hook + (lambda () + (setq timer + (run-with-idle-timer + 0.3 'repeat + (lambda () + (with-selected-window (minibuffer-window) + (setq minibuffer-scroll-window + (get-buffer-window buffer)) + (let ((input (minibuffer-contents))) + (when (> (length input) 1) + (setq input (substring input 0 1)) + (delete-minibuffer-contents) + (insert input)) + (when (not (string=3D input pat)) + (setq pat input)))) + (with-current-buffer buffer + (let ((ov (make-overlay (point-min) (point-min= )))) + (goto-char (point-min)) + (if (string=3D pat "") + (remove-overlays) + (if (re-search-forward (concat "^" pat) ni= l t) + (progn (move-overlay + ov + (match-beginning 0) (match-end= 0)) + (overlay-put ov 'face 'match)) + (with-selected-window (minibuffer-window) + (minibuffer-message + "Register `%s' is available" pat)))))= ))))) + (setq result (read-from-minibuffer prompt))) + (cl-assert (and result (not (string=3D result ""))) + nil "No register specified") + (string-to-char result)) + (when timer (cancel-timer timer)) (let ((w (get-buffer-window buffer))) (and (window-live-p w) (delete-window w))) (and (get-buffer buffer) (kill-buffer buffer))))) =2D-=20 Thierry --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQHHBAEBCgAxFiEEI9twfRN7r3nig/xwDsVtFB0W75MFAmUiUOoTHHRoaWV2b2xA cG9zdGVvLm5ldAAKCRAOxW0UHRbvkwV2DACyC6jppr3YWyfOZmMRonIlUWloy9Ox xJ1uQHZWFaD8GP+TPOg64kns7051J882HMe+M9kd+WriRAE7+P4LR4IXG4YKDmvR c8+w8OG3PzH7XWsPDWrDXubGTFNgHA26Lz71YoIRq35OBD0TQow4aFUtraBO/Vzy AqijAZ88ka2ZqQPxZK6gh4kxtWyw7gY3f6XPrJq1S4ZNQLcSZAMCIP+BDD1iyFgB UKLYr6wrEF2tlAgFJa9dgCJv8GzkYMKgySX5tVG0lDVL2oAitolj3YP01fe2if61 OcMa0z9QWMgjpCCIh5gd0l5+hhZrwG+4wOOSlVph1KN65cEuLK5K2Q/FakruNL2w PtR1DQDr+G5/NCI4I9Yu4cJBOm8aY5qH5t/KZ2D8djG4pgjHN1+fAXJfj4PbFOcB hFuihDTI9JVmOw+ZqT+vyKePwv1ABSLoTU41j3DQRUDkFI8Gjhq3eSQyjpUfas5Q nS9UD9uwW00bx0DjwtCz1uq46zbt6wr4V7o= =PAiw -----END PGP SIGNATURE----- --=-=-=--