From: Tino Calancha <tino.calancha@gmail.com>
To: Andreas Schwab <schwab@linux-m68k.org>
Cc: 25860@debbugs.gnu.org,
Marek Twardochlib <wasserwerk.studio@googlemail.com>
Subject: bug#25860: 25.1; Double macro execution
Date: Sat, 25 Feb 2017 19:10:20 +0900 [thread overview]
Message-ID: <871sumwpgz.fsf@calancha-pc> (raw)
In-Reply-To: <8760jyx1wv.fsf@calancha-pc> (Tino Calancha's message of "Sat, 25 Feb 2017 14:41:36 +0900")
Tino Calancha <tino.calancha@gmail.com> writes:
> II) ;;; Using macro `insert-a' we insert "a" _twice_; so you need to remove
> ;;; <<insert-a>> 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: <<insert-a>> a RET
>
> Command: last-kbd-macro
> Key: none
>
> Macro:
>
> <<insert-a>> ;; 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 <tino.calancha@gmail.com>
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
next prev parent reply other threads:[~2017-02-25 10:10 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-24 9:23 bug#25860: 25.1; Double macro execution Marek Twardochlib
2017-02-24 14:10 ` Andreas Schwab
2017-02-25 5:41 ` Tino Calancha
2017-02-25 10:10 ` Tino Calancha [this message]
2017-02-25 13:27 ` npostavs
2017-02-25 14:48 ` Tino Calancha
2017-02-25 15:26 ` Marek Twardochlib
2017-02-26 5:04 ` Tino Calancha
2017-02-26 7:12 ` npostavs
2017-02-26 15:33 ` Eli Zaretskii
2017-02-26 16:02 ` npostavs
2017-02-27 15:57 ` Eli Zaretskii
2017-02-27 17:18 ` Noam Postavsky
2017-03-03 14:21 ` Eli Zaretskii
2017-09-29 10:29 ` Marek Twardochlib
2017-09-29 11:41 ` 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=871sumwpgz.fsf@calancha-pc \
--to=tino.calancha@gmail.com \
--cc=25860@debbugs.gnu.org \
--cc=schwab@linux-m68k.org \
--cc=wasserwerk.studio@googlemail.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).