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#25860: 25.1; Double macro execution Date: Sat, 25 Feb 2017 19:10:20 +0900 Message-ID: <871sumwpgz.fsf@calancha-pc> References: <87zihbbrxr.fsf@linux-m68k.org> <8760jyx1wv.fsf@calancha-pc> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1488017472 11746 195.159.176.226 (25 Feb 2017 10:11:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 25 Feb 2017 10:11:12 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) Cc: 25860@debbugs.gnu.org, Marek Twardochlib To: Andreas Schwab Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Feb 25 11:11: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 1chZJj-0002M8-8V for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 Feb 2017 11:11:07 +0100 Original-Received: from localhost ([::1]:41995 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chZJn-00066x-Lo for geb-bug-gnu-emacs@m.gmane.org; Sat, 25 Feb 2017 05:11:11 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:38869) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1chZJh-00066p-Jv for bug-gnu-emacs@gnu.org; Sat, 25 Feb 2017 05:11:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1chZJe-0002jn-Ea for bug-gnu-emacs@gnu.org; Sat, 25 Feb 2017 05:11:05 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:56987) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1chZJe-0002jj-BO for bug-gnu-emacs@gnu.org; Sat, 25 Feb 2017 05:11:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1chZJe-0006kU-2z for bug-gnu-emacs@gnu.org; Sat, 25 Feb 2017 05:11:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 25 Feb 2017 10:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 25860 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 25860-submit@debbugs.gnu.org id=B25860.148801743225905 (code B ref 25860); Sat, 25 Feb 2017 10:11:02 +0000 Original-Received: (at 25860) by debbugs.gnu.org; 25 Feb 2017 10:10:32 +0000 Original-Received: from localhost ([127.0.0.1]:55186 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1chZJA-0006jl-Hf for submit@debbugs.gnu.org; Sat, 25 Feb 2017 05:10:32 -0500 Original-Received: from mail-pg0-f66.google.com ([74.125.83.66]:35926) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1chZJ8-0006jY-Hu for 25860@debbugs.gnu.org; Sat, 25 Feb 2017 05:10:30 -0500 Original-Received: by mail-pg0-f66.google.com with SMTP id z128so6288367pgb.3 for <25860@debbugs.gnu.org>; Sat, 25 Feb 2017 02:10:30 -0800 (PST) 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=aRce/GNghD3ntrp13PA0IBsTSxBXRvo3Hw4P0TH+yqE=; b=Ar4vghTQbQfRZcJqUHGYF4LIui/YxZFPCUzNVLY/B+fQzlo4VJg68sOOhdi4jt5BKO 5Q5M3n6IRr/tigYzan/X9xa5FdSR9xzuQ7+6/RYgD3l/peocTGtCZLV3VbuQlKS/iWaJ wK/BieFu3IszOeUNDS+xMcNU7zZmOKecP+/HmGnAAfmnvaRF0xYBBSHVtRPEurgcMxpZ BCQcWOypVSHrrUH796pyPBPMo+7tX3DhUemYVy7rS2dBv3jAQlYAZdeYxv3bieDknTKg Dx1XNw0y4bVSNwrztHPbe++em8e45fUBeKcaqyxAkSTvln3pJj1SFgSGScQ8iZ4p9Ms1 L8Qg== 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=aRce/GNghD3ntrp13PA0IBsTSxBXRvo3Hw4P0TH+yqE=; b=jo+vzgOJd8XCE5xjrvZ0PB4DO3JBPMfj++Z/V4LOknQhl8RqvK1/dyoZQTggRKFvi4 dODxrFyjF3s7b1F9MeLqA7nmqo+Ednz0kPDgaixxRNpxqAAoubOHd9yGxS4xR5gOlXa7 3wMDjAq3Knq4u9GCNsaoOFOfwxBut7zBxl4ZaM3fOJ1DZEZXJpHLk3xNX4GEvCMU+l9x 66xko1VlmzYWojX8xrFsPTekGgFmvOnymoE1QK1IKM9QD1I59hzIOjp81FEJoOKiAcfk bwvRPu+gn+1iRKsdpeU+t5ko02U4hbVlUOdaRA/rPY0xrqJYvelyHx9mNed7vacBv1fN qxRA== X-Gm-Message-State: AMke39lEUCgm6aMCo3KT+rC05DdEeDe7h+ihOVhIOxR1FzdzyzmS+gwF5Q4PKUsujRdj6Q== X-Received: by 10.99.45.133 with SMTP id t127mr9171043pgt.224.1488017424916; Sat, 25 Feb 2017 02:10:24 -0800 (PST) Original-Received: from calancha-pc (104.81.147.124.dy.bbexcite.jp. [124.147.81.104]) by smtp.gmail.com with ESMTPSA id u129sm19580388pfb.130.2017.02.25.02.10.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 25 Feb 2017 02:10:24 -0800 (PST) In-Reply-To: <8760jyx1wv.fsf@calancha-pc> (Tino Calancha's message of "Sat, 25 Feb 2017 14:41:36 +0900") 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:129773 Archived-At: Tino Calancha writes: > II) ;;; Using macro `insert-a' we insert "a" _twice_; so you need to remove > ;;; <> line by hand: > F3 M-x insert-a RET F4 > C-x C-k e RET > ;; Keyboard Macro Editor. Press C-c C-c to finish; press C-x k RET to cancel. > ;; Original keys: <> a RET > > Command: last-kbd-macro > Key: none > > Macro: > > <> ;; insert-a > a ;; self-insert-command > RET ;; newline How about introduce a function doing such clean up for us? ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; >From 9c3b20f573b3f448ba98fa4f1f5c950bd2e9f39a Mon Sep 17 00:00:00 2001 From: Tino Calancha Date: Sat, 25 Feb 2017 19:05:43 +0900 Subject: [PATCH] Prevent from unintentional duplicate kbd calls lisp/kmacro.el (kmacro-avoid-double-kbd-calls): New defun. (kmacro-end-macro): Use it (Bug#25860). --- lisp/kmacro.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lisp/kmacro.el b/lisp/kmacro.el index 838a492b6c..baa1c4bc7a 100644 --- a/lisp/kmacro.el +++ b/lisp/kmacro.el @@ -592,6 +592,16 @@ kmacro-start-macro (if (and defining-kbd-macro append) (setq defining-kbd-macro 'append))))) +(declare-function edmacro-finish-edit "edmacro") + +;; Prevent from unintentional duplicate kbd calls (Bug#25860). +(defun kmacro--avoid-double-kbd-calls () + (edit-kbd-macro [f4] t) + (while (re-search-forward "<<\\([^>]+\\)>>" nil t) + (let ((sym (intern (match-string 1)))) + (when (get sym 'kmacro) + (delete-region (match-beginning 0) (match-end 0))))) + (edmacro-finish-edit)) ;;;###autoload (defun kmacro-end-macro (arg) @@ -609,6 +619,7 @@ kmacro-end-macro ;; Just ignore it when executing the macro. (unless executing-kbd-macro (end-kbd-macro arg #'kmacro-loop-setup-function) + (kmacro--avoid-double-kbd-calls) (when (and last-kbd-macro (= (length last-kbd-macro) 0)) (setq last-kbd-macro nil) (message "Ignore empty macro") -- 2.11.0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; In GNU Emacs 26.0.50 (build 8, x86_64-pc-linux-gnu, GTK+ Version 3.22.7) of 2017-02-25 Repository revision: ecbd5f9ac6eb2d31241657bbb3e3f9b860391054