From: Tino Calancha <tino.calancha@gmail.com>
To: Paul Rankin <hello@paulwrankin.com>
Cc: 27634@debbugs.gnu.org
Subject: bug#27634: 25.2.1; C-g does not quit register-read-with-preview
Date: Mon, 10 Jul 2017 15:33:42 +0900 [thread overview]
Message-ID: <87h8ykdcmx.fsf@calancha-pc> (raw)
In-Reply-To: <1499659134.3804557.1035526184.45B0CA20@webmail.messagingengine.com> (Paul Rankin's message of "Mon, 10 Jul 2017 13:58:54 +1000")
Paul Rankin <hello@paulwrankin.com> writes:
> When saving to a register C-g does not quit but instead saves to the register "C-g".
>
> To reproduce:
>
> 1. $ emacs -Q
> 2. M-x point-to-register [C-x r SPC]
> 3. C-g
>
> Expected results:
>
> C-g should call keyboard-quit and escape point-to-register
>
> Actual results:
>
> Point marker is saved to register "C-g".
> I have worked around this with the following patch to register.el.gz:
>
> @@ -164,7 +164,7 @@
> help-chars)
> (unless (get-buffer-window buffer)
> (register-preview buffer 'show-empty)))
> - (if (characterp last-input-event) last-input-event
> + (if (< 31 last-input-event 127) last-input-event
> (error "Non-character input-event")))
> (and (timerp timer) (cancel-timer timer))
> (let ((w (get-buffer-window buffer)))
>
> However, I think this will not work on international keyboards and so is probably a poor fix.
How about the following?
@@ -164,6 +164,8 @@ register-read-with-preview
help-chars)
(unless (get-buffer-window buffer)
(register-preview buffer 'show-empty)))
+ (when (eq (string-to-char "\C-g") 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---------------start------------->8---
commit 51de600be1351704d4e435a4977d63b3d4e04eaf
Author: Tino Calancha <tino.calancha@gmail.com>
Date: Mon Jul 10 15:22:32 2017 +0900
Don't set registers in 'C-g'
That key is reserved to abort commands (Bug#27634).
* lisp/register-tests.el (register-read-with-preview):
Abort when user inputs 'C-g'.
* test/lisp/register-tests.el (register-test-bug27634): Add test.
diff --git a/lisp/register.el b/lisp/register.el
index 7cc3ccd870..19b7dee4b9 100644
--- a/lisp/register.el
+++ b/lisp/register.el
@@ -164,6 +164,8 @@ register-read-with-preview
help-chars)
(unless (get-buffer-window buffer)
(register-preview buffer 'show-empty)))
+ (when (eq (string-to-char "\C-g") last-input-event)
+ (keyboard-quit))
(if (characterp last-input-event) last-input-event
(error "Non-character input-event")))
(and (timerp timer) (cancel-timer timer))
diff --git a/test/lisp/register-tests.el b/test/lisp/register-tests.el
new file mode 100644
index 0000000000..30c1468e25
--- /dev/null
+++ b/test/lisp/register-tests.el
@@ -0,0 +1,40 @@
+;;; register-tests.el --- tests for electric.el
+
+;; Copyright (C) 2017 Free Software Foundation, Inc.
+
+;; Author: Tino Calacha <tino.calancha@gmail.com>
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+\f
+;;; Code:
+(require 'ert)
+(require 'cl-lib)
+
+(ert-deftest register-test-bug27634 ()
+ "Test for http://debbugs.gnu.org/27634 ."
+ (cl-letf (((symbol-function 'read-key) #'ignore)
+ (last-input-event 7)
+ (register-alist nil))
+ (should (equal 'quit
+ (condition-case err
+ (call-interactively 'point-to-register)
+ (quit (car err)))))
+ (should-not register-alist)))
+
+(provide 'register-tests)
+;;; register-tests.el ends here
--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-10
Repository revision: 273f4bde39af5d87f10fd58f35b666dfa8a996a3
next prev parent reply other threads:[~2017-07-10 6:33 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-10 3:58 bug#27634: 25.2.1; C-g does not quit register-read-with-preview Paul Rankin
2017-07-10 6:33 ` Tino Calancha [this message]
2017-07-10 7:20 ` Paul Rankin
2017-07-10 7:59 ` Tino Calancha
2017-07-10 17:06 ` Eli Zaretskii
2017-07-11 4:14 ` Paul Rankin
2017-07-11 4:48 ` Tino Calancha
2017-07-11 5:07 ` Paul Rankin
2017-07-11 5:50 ` Tino Calancha
2017-07-11 7:20 ` Andreas Schwab
2017-07-11 14:36 ` Eli Zaretskii
2017-07-12 2:12 ` Paul Rankin
2017-07-10 19:01 ` Andreas Schwab
2017-07-21 3:47 ` Allen Li
2017-07-21 6:19 ` Tino Calancha
2017-07-21 8:40 ` Eli Zaretskii
2017-07-21 8:55 ` Tino Calancha
2017-07-25 2:45 ` Tino Calancha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87h8ykdcmx.fsf@calancha-pc \
--to=tino.calancha@gmail.com \
--cc=27634@debbugs.gnu.org \
--cc=hello@paulwrankin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).