[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#27634: 25.2.1; C-g does not quit register-read-with-preview

From: Tino Calancha
Subject: bug#27634: 25.2.1; C-g does not quit register-read-with-preview
Date: Fri, 21 Jul 2017 15:19:03 +0900
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

Allen Li <address@hidden> writes:

> It sounds like there's a general consensus on how to fix this.  Tino, would 
> you care to post a finalized patch?
> Note: bug#25370 is a duplicate of this, it should probably be marked closed, 
> wontfix, etc.
Thanks, i merged this thread with your bug report.

Let's discuss following patch:

*) Call `keyboard-quit' whenever last-input-event is
    ?\C-g or 'escape or ?\C-\[.

**) Updated the manual to point out that non-alphanumeric
    keys are valid to store registers as well.

Let me know if that is OK or if we need a fine-grained control.

--8<-----------------------------cut here---------------start------------->8---
commit 484faa217fe5a76d12ce266bc3f84737da73f0ae
Author: Tino Calancha <address@hidden>
Date:   Fri Jul 21 15:08:06 2017 +0900

    register-read-with-preview: Quit if user input C-g or ESC
    * lisp/register.el (register-read-with-preview):
    Quit if user input C-g or ESC (bug#27634).
    * doc/emacs/regs.texi (Registers): Update manual.

diff --git a/doc/emacs/regs.texi b/doc/emacs/regs.texi
index 7369f6b05b..40e3e2c1c3 100644
--- a/doc/emacs/regs.texi
+++ b/doc/emacs/regs.texi
@@ -15,7 +15,10 @@ Registers
   Each register has a name that consists of a single character, which
 we will denote by @var{r}; @var{r} can be a letter (such as @samp{a})
 or a number (such as @samp{1}); case matters, so register @samp{a} is
-not the same as register @samp{A}.
+not the same as register @samp{A}.  You can also set a register in
+non-alphanumeric characters, for instance @samp{*} or @samp{C-d}.
+Note, it's not possible to set a register in @samp{C-g} or @samp{ESC},
+because these keys are reserved to terminate interactive commands.
 @findex view-register
   A register can store a position, a piece of text, a rectangle, a
diff --git a/lisp/register.el b/lisp/register.el
index 7cc3ccd870..e395963f56 100644
--- a/lisp/register.el
+++ b/lisp/register.el
@@ -164,6 +164,10 @@ register-read-with-preview
            (unless (get-buffer-window buffer)
              (register-preview buffer 'show-empty)))
+          (when (or (eq ?\C-g last-input-event)
+                    (eq 'escape last-input-event)
+                    (eq ?\C-\[ last-input-event))
+            (keyboard-quit))
          (if (characterp last-input-event) last-input-event
            (error "Non-character input-event")))
       (and (timerp timer) (cancel-timer timer))
--8<-----------------------------cut here---------------end--------------->8---
In GNU Emacs 26.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.11)
 of 2017-07-21
Repository revision: 1d559e384b467b3f74e8b78695f124b561c884d9

reply via email to

[Prev in Thread] Current Thread [Next in Thread]