From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#27634: 25.2.1; C-g does not quit register-read-with-preview Date: Mon, 10 Jul 2017 15:33:42 +0900 Message-ID: <87h8ykdcmx.fsf@calancha-pc> References: <1499659134.3804557.1035526184.45B0CA20@webmail.messagingengine.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1499668461 13806 195.159.176.226 (10 Jul 2017 06:34:21 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 10 Jul 2017 06:34:21 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: 27634@debbugs.gnu.org To: Paul Rankin Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jul 10 08:34:08 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dUSGl-0002qG-Bv for geb-bug-gnu-emacs@m.gmane.org; Mon, 10 Jul 2017 08:34:07 +0200 Original-Received: from localhost ([::1]:38704 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUSGq-0001lV-Dl for geb-bug-gnu-emacs@m.gmane.org; Mon, 10 Jul 2017 02:34:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:52184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUSGj-0001lP-Jl for bug-gnu-emacs@gnu.org; Mon, 10 Jul 2017 02:34:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUSGg-0001Hr-HA for bug-gnu-emacs@gnu.org; Mon, 10 Jul 2017 02:34:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:56798) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dUSGg-0001Hg-Dq for bug-gnu-emacs@gnu.org; Mon, 10 Jul 2017 02:34:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dUSGg-0004hS-5Q for bug-gnu-emacs@gnu.org; Mon, 10 Jul 2017 02:34:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 10 Jul 2017 06:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27634 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 27634-submit@debbugs.gnu.org id=B27634.149966843518052 (code B ref 27634); Mon, 10 Jul 2017 06:34:02 +0000 Original-Received: (at 27634) by debbugs.gnu.org; 10 Jul 2017 06:33:55 +0000 Original-Received: from localhost ([127.0.0.1]:59475 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dUSGZ-0004h6-7K for submit@debbugs.gnu.org; Mon, 10 Jul 2017 02:33:55 -0400 Original-Received: from mail-pg0-f50.google.com ([74.125.83.50]:36110) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dUSGX-0004gq-Gg for 27634@debbugs.gnu.org; Mon, 10 Jul 2017 02:33:54 -0400 Original-Received: by mail-pg0-f50.google.com with SMTP id u62so44334096pgb.3 for <27634@debbugs.gnu.org>; Sun, 09 Jul 2017 23:33:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=io7OCtmr4nHPcoqb4icLTdTzvA263jIE196wg+QFAmM=; b=M0Rjy+KZosACmJsdkt/pAY+aSxtKXqlmRAVOcuvsQVf7tIimDYG3htc9/zVIujEahN /tlGGHmzcc6oZFNfWi7RPRE/B6qFmSDTlArs8prIdLlh0bdRDW+17n2zVWgdWqFJ+lmM S6b8ugvyHbT1EZl+LfNlCZXkbc0DRcR1RXwMvZ1dnpqlCbzaKdRIm+EszurXQz4sybq0 zdyWQ2z+WUyONBxYEvagXtU6Y1WL1MGD0Z6+93EyuN/waKUcfEdouGGqg56xIRN+sW6q crMdIMRdWZ/vcAw8QyXg1hNgQTLWuFuJbD+VjHsyzKjLgPSIF1dy5glczxNTPyHGNt0t NdNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=io7OCtmr4nHPcoqb4icLTdTzvA263jIE196wg+QFAmM=; b=f8XncH5QKN1g2jHNKbW3pQ5QPjTt6go6SA2Hh0Vk6FS9Rsix8tNVXTyem3HCtLWY4g 8OQRJjLRCBNsjgo3kualT6Omqkykxtb0uobnT/2ItJYipCB/sHcBxAkmNec7TFLde/MS 1bd2PAX2LGa77M3DJsZffysvrfyorOmnC4j2VSBavZx2rHVekv2W+J0JNbkcekzrxfym /3i2X8cEDwKumtjpihL8j7dshBz8F/5EEAV1Rxy5J6C5wes09mssrkVI5NyWO6Hgwrxy QAN2MCpBBThPZOR3TEWHG7uUYciVjwCqMrOzM19DPDkdGwPNtN1a5lhwAOK8KdeebCAq vbJw== X-Gm-Message-State: AIVw113Ng5pWpR+FfoyBne2LeEBHtjNDvugXuxYvu1eo9wFjw5VHoTEn k+UFDuWyk2e/0Q== X-Received: by 10.99.143.94 with SMTP id r30mr13132652pgn.102.1499668427224; Sun, 09 Jul 2017 23:33:47 -0700 (PDT) Original-Received: from calancha-pc (170.224.128.101.dy.bbexcite.jp. [101.128.224.170]) by smtp.gmail.com with ESMTPSA id c62sm18933701pfb.93.2017.07.09.23.33.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 09 Jul 2017 23:33:46 -0700 (PDT) In-Reply-To: <1499659134.3804557.1035526184.45B0CA20@webmail.messagingengine.com> (Paul Rankin's message of "Mon, 10 Jul 2017 13:58:54 +1000") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:134386 Archived-At: Paul Rankin 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 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 +;; 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 . + +;;; Commentary: + + +;;; 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