GNU logs - #61549, boring messages


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions
Resent-From: Alex Bochannek <alex@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 16 Feb 2023 08:19:02 +0000
Resent-Message-ID: <handler.61549.B.16765355244710 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: report 61549
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: 61549 <at> debbugs.gnu.org
X-Debbugs-Original-To: bug-gnu-emacs@HIDDEN
Received: via spool by submit <at> debbugs.gnu.org id=B.16765355244710
          (code B ref -1); Thu, 16 Feb 2023 08:19:02 +0000
Received: (at submit) by debbugs.gnu.org; 16 Feb 2023 08:18:44 +0000
Received: from localhost ([127.0.0.1]:34785 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSZTW-0001Dt-Pv
	for submit <at> debbugs.gnu.org; Thu, 16 Feb 2023 03:18:44 -0500
Received: from lists.gnu.org ([209.51.188.17]:46082)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <alex@HIDDEN>) id 1pSZTR-0001Dh-C8
 for submit <at> debbugs.gnu.org; Thu, 16 Feb 2023 03:18:41 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <alex@HIDDEN>)
 id 1pSZTQ-0004nY-Qt
 for bug-gnu-emacs@HIDDEN; Thu, 16 Feb 2023 03:18:36 -0500
Received: from ns.lapseofthought.com ([50.0.39.240]
 helo=mail.lapseofthought.com)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <alex@HIDDEN>)
 id 1pSZTM-0005b6-Q9
 for bug-gnu-emacs@HIDDEN; Thu, 16 Feb 2023 03:18:36 -0500
Received: from awb-mbp.local (c-73-92-249-246.hsd1.ca.comcast.net
 [73.92.249.246])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by mail.lapseofthought.com (Postfix) with ESMTPSA id 4PHSVG0nlwz3pf5q
 for <bug-gnu-emacs@HIDDEN>; Thu, 16 Feb 2023 00:17:26 -0800 (PST)
Authentication-Results: ORIGINATING;
 auth=pass smtp.auth=alex smtp.mailfrom=alex@HIDDEN
From: Alex Bochannek <alex@HIDDEN>
Date: Thu, 16 Feb 2023 00:17:25 -0800
Message-ID: <m2a61ef2i2.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=50.0.39.240; envelope-from=alex@HIDDEN;
 helo=mail.lapseofthought.com
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

--=-=-=
Content-Type: text/plain

Hello!

I have been working on blog posts about keyboard macros and found that
it would be useful to have comparison functions for the keyboard macro
counter.

I implemented two functions to load and save macro counter values from
and to number registers; three comparison functions of the macro counter
with a number register that conditionally increment the counter; three
comparison functions of the macro counter with a prefix that terminate
the macro execution. This simplifies handling multiple counters and
conditional macro termination.

I am attaching the changes to:
  emacs.texi
  kmacro.texi
  NEWS
  kmacro.el
  kmacro-tests.el

I hope this functionality is useful and that I followed the coding and
style standards.

Thanks!

	Advanced keyboard macro counter commands for register
	integration and conditional macro termination

	* doc/emacs/emacs.texi (Top):
	Document advanced keyboard macro counter commands.

	* doc/emacs/kmacro.texi (Keyboard Macros, Keyboard Macro Counter):
	Document advanced keyboard macro counter commands.

	* etc/NEWS:
	Document advanced keyboard macro counter commands.

	* lisp/kmacro.el (kmacro-keymap, kmacro-reg-load-counter)
	(kmacro-reg-save-counter, kmacro-reg-add-counter-equal)
	(kmacro-reg-add-counter-equal, kmacro-reg-add-counter-less)
	(kmacro-reg-add-counter-greater, kmacro-reg-add-counter)
	(kmacro-quit-counter-equal, kmacro-quit-counter-less)
	(kmacro-quit-counter-greater, kmacro-quit-counter):
	Add advanced keyboard macro counter commands to kmacro keymap.
	Implement advanced keyboard macro counter commands.

	* test/lisp/kmacro-tests.el (kmacro-tests-test-reg-load)
	(kmacro-tests-test-reg-save)
	(kmacro-tests-test-reg-add-counter-equal-01)
	(kmacro-tests-test-reg-add-counter-equal-02)
	(kmacro-tests-test-reg-add-counter-equal-03)
	(kmacro-tests-test-reg-add-counter-equal-04)
	(kmacro-tests-test-reg-add-counter-less)
	(kmacro-tests-test-reg-add-counter-greater)
	(kmacro-tests-test-quit-counter-equal-01)
	(kmacro-tests-test-quit-counter-equal-02)
	(kmacro-tests-test-quit-counter-equal-03)
	(kmacro-tests-test-quit-counter-equal-04)
	(kmacro-tests-test-quit-counter-less)
	(kmacro-tests-test-quit-counter-greater):
	Implement unit tests for advanced keyboard macro counter
	commands.

--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi
index 7071ea44edd..2584dce8d44 100644
--- a/doc/emacs/emacs.texi
+++ b/doc/emacs/emacs.texi
@@ -434,6 +434,7 @@ Top
 * Basic Keyboard Macro::     Defining and running keyboard macros.
 * Keyboard Macro Ring::      Where previous keyboard macros are saved.
 * Keyboard Macro Counter::   Inserting incrementing numbers in macros.
+* Advanced Macro Counter::   Advanced macro counter commands.
 * Keyboard Macro Query::     Making keyboard macros do different things each
                                 time.
 * Save Keyboard Macro::      Giving keyboard macros names; saving them in

--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/doc/emacs/kmacro.texi b/doc/emacs/kmacro.texi
index fc1402b489d..27c84c0f96f 100644
--- a/doc/emacs/kmacro.texi
+++ b/doc/emacs/kmacro.texi
@@ -35,6 +35,7 @@ Keyboard Macros
 * Basic Keyboard Macro::     Defining and running keyboard macros.
 * Keyboard Macro Ring::      Where previous keyboard macros are saved.
 * Keyboard Macro Counter::   Inserting incrementing numbers in macros.
+* Advanced Macro Counter::   Advanced macro counter commands.
 * Keyboard Macro Query::     Making keyboard macros do different things each
                                time.
 * Save Keyboard Macro::      Giving keyboard macros names; saving them in
@@ -364,6 +365,123 @@ Keyboard Macro Counter
 keyboard macro counter.  @xref{Number Registers}.  For most purposes,
 it is simpler to use a keyboard macro counter.
 
+@node Advanced Macro Counter
+@section Advanced Macro Counter Commands
+
+  The counter associated with a keyboard macro is sufficient in most
+cases.  If additional counters are required for a macro, registers can
+be used and these advanced macro counter commands simplify the
+interaction between the two.  Additional commands are provided to
+terminate a macro after a predefined number of runs.
+
+
+@table @kbd
+@item C-x C-k C-r l
+Load the value of a number register into the macro counter
+(@code{kmacro-reg-load-counter}).
+@item C-x C-k C-r s
+Save the value of the macro counter to a number register
+(@code{kmacro-reg-save-counter}).
+@end table
+
+@table @kbd
+@item C-x C-k C-r a =
+Compare if the macro counter is equal to the value of a register and
+increment the counter if it is (@code{kmacro-reg-add-counter-equal}).
+@item C-x C-k C-r a <
+Compare if the macro counter is less than the value of a register and
+increment the counter if it is (@code{kmacro-reg-add-counter-less}).
+@item C-x C-k C-r a >
+Compare if the macro counter is greater than the value of a register
+and increment the counter if it is
+(@code{kmacro-reg-add-counter-greater}).
+@end table
+
+@table @kbd
+@item C-x C-k C-q =
+Compare if the macro counter is equal to the prefix and terminate the
+macro if it is (@code{kmacro-quit-counter-equal}).
+@item C-x C-k C-q <
+Compare if the macro counter is less than the prefix and terminate the
+macro if it is (@code{kmacro-quit-counter-less}).
+@item C-x C-k C-q >
+Compare if the macro counter is greater than the prefix and terminate
+the macro if it is (@code{kmacro-quit-counter-greater}).
+@end table
+
+@findex kmacro-reg-load-counter
+@kindex C-x C-k C-r l
+@findex kmacro-reg-save-counter
+@kindex C-x C-k C-r s
+  The command @kbd{C-x C-k C-r l} (@code{kmacro-reg-load-counter})
+prompts for the register name from which to load a number into the
+macro counter.  The command @kbd{C-x C-k C-r s}
+(@code{kmacro-reg-save-counter}) prompts for the register name into
+which to save the macro counter's value.  Both @kbd{C-x C-k C-r l}
+(@code{kmacro-reg-load-counter}) and @kbd{C-x C-k C-r s}
+(@code{kmacro-reg-save-counter}) show a preview of the registers by
+default.  @xref{Registers}.  Both commands can be used during or
+outside a keyboard macro definition.
+
+@findex kmacro-reg-add-counter-equal
+@kindex C-x C-k C-r a =
+@findex kmacro-reg-add-counter-less
+@kindex C-x C-k C-r a <
+@findex kmacro-reg-add-counter-greater
+@kindex C-x C-k C-r a >
+  The @kbd{C-x C-k C-r a =} (@code{kmacro-reg-add-counter-equal}),
+@kbd{C-x C-k C-r a <} (@code{kmacro-reg-add-counter-less}), and
+@kbd{C-x C-k C-r a >} (@code{kmacro-reg-add-counter-greater}) commands
+all follow the same pattern.  During keyboard macro definition, the
+command prompts for a register name (with preview by default), the
+contents of which will be compared with the macro counter's value.  If
+the counter is equal to (@code{=}), less than (@code{<}), or greater
+than (@code{>}) the number register's contents, the counter will be
+incremented by the numeric prefix or one if no prefix was given to the
+command.
+
+  For example,
+
+@example
+C-u 2 C-x C-k C-r a > N
+@end example
+
+@noindent
+compares the counter with the contents of register @code{N} and if the
+counter is greater than that, increases it by two.
+
+@findex kmacro-quit-counter-equal
+@kindex C-x C-k C-q =
+@findex kmacro-quit-counter-less
+@kindex C-x C-k C-q <
+@findex kmacro-quit-counter-greater
+@kindex C-x C-k C-q >
+  Finally, the @kbd{C-x C-k C-q =} (@code{kmacro-quit-counter-equal}),
+@kbd{C-x C-k C-q <} (@code{kmacro-quit-counter-less}), and @kbd{C-x
+C-k C-q >} (@code{kmacro-quit-counter-greater}) commands compare the
+macro counter with the prefix given and terminate the execution of the
+macro, if the comparison succeeds.  If no numeric prefix or only
+@code{C-u} are given, the counter will be compared with zero.  The
+macro is terminated using the @code{keyboard-quit} function.  Using
+this command to exit from a macro that has been called by another
+macro is not supported, the entire executing macro is terminated.
+
+  The quit commands can be used to construct the equivalent of a
+@code{while}-loop. This example will stop after ten executions
+assuming the starting value for the macro counter is the default zero.
+
+@example
+C-u 10 C-x C-k C-q = C-x C-k C-i @key{RET}
+@end example
+
+  With the default counter value of zero, the macro called with a
+prefix of @code{C-u C-u} to execute sixteen times, will stop after ten
+iterations.  The counter values that have been inserted will be from 0
+to 9.  If the counter starts out a different value below ten, it will
+still stop at ten, because the counter does not actually count macro
+executions, but is incremented explicitly by the @code{C-x C-k C-i}
+command.
+
 @node Keyboard Macro Query
 @section Executing Macros with Variations

--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/etc/NEWS b/etc/NEWS
index 4fbe09e0541..d5a3ebb1df5 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -187,6 +187,25 @@ This command adds a docstring comment to the current defun.  If a
 comment already exists, point is only moved to the comment.  It is
 bound to 'C-c C-d' in 'go-ts-mode'.
 
+** Kmacro
+
++++
+*** New Advanced Macro Counter functions.
+New commands have been added to to implement advanced macro counter
+functions.
+
+The commands 'C-x C-k C-r l' and 'C-x C-k C-r s' load and save the
+macro counter from a to a number register respectively.
+
+The commands 'C-x C-k C-r a =', 'C-x C-k C-r a <', and
+'C-x C-k C-r a >' compare the macro counter with the contents of a
+number register and increment the counter by a prefix if the
+comparison succeeds.
+
+The commands 'C-x C-k C-q =', 'C-x C-k C-q <', and 'C-x C-k C-q >'
+compare the macro counter with a prefix and terminate the macro if the
+comparison succeeds.
+
 
 * New Modes and Packages in Emacs 30.1
 
--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/lisp/kmacro.el b/lisp/kmacro.el
index 94d8794bd23..e7c3f75efd0 100644
--- a/lisp/kmacro.el
+++ b/lisp/kmacro.el
@@ -183,10 +183,18 @@ kmacro-keymap
   "C-l"  #'kmacro-call-ring-2nd-repeat
 
   ;; macro counter
-  "C-f"  #'kmacro-set-format
-  "C-c"  #'kmacro-set-counter
-  "C-i"  #'kmacro-insert-counter
-  "C-a"  #'kmacro-add-counter
+  "C-f"     #'kmacro-set-format
+  "C-c"     #'kmacro-set-counter
+  "C-i"     #'kmacro-insert-counter
+  "C-a"     #'kmacro-add-counter
+  "C-r l"   #'kmacro-reg-load-counter
+  "C-r s"   #'kmacro-reg-save-counter
+  "C-r a =" #'kmacro-reg-add-counter-equal
+  "C-r a <" #'kmacro-reg-add-counter-less
+  "C-r a >" #'kmacro-reg-add-counter-greater
+  "C-q ="   #'kmacro-quit-counter-equal
+  "C-q <"   #'kmacro-quit-counter-less
+  "C-q >"   #'kmacro-quit-counter-greater
 
   ;; macro editing
   "C-e"  #'kmacro-edit-macro-repeat
@@ -347,6 +355,89 @@ kmacro-add-counter
     (kmacro-display-counter)))
 
 
+(defun kmacro-reg-load-counter (register)
+  "Load the value of a register into `kmacro-counter'"
+  (interactive
+   (list (register-read-with-preview "Load register to counter: ")))
+  (let ((register-val (get-register register)))
+    (when (numberp register-val)
+     (setq kmacro-counter register-val))))
+
+
+(defun kmacro-reg-save-counter (register)
+  "Save the value of `kmacro-counter' to a register"
+  (interactive
+   (list (register-read-with-preview "Save counter to register: ")))
+  (set-register register kmacro-counter))
+
+
+(defun kmacro-reg-add-counter-equal (&optional arg)
+  "Increment counter by ARG if it is equal to register value"
+  (interactive "p")
+  (let
+      ((register (register-read-with-preview "Compare counter to register: ")))
+    (kmacro-reg-add-counter '= register arg)))
+
+
+(defun kmacro-reg-add-counter-less (&optional arg)
+  "Increment counter by ARG if it is less than register value"
+  (interactive "p")
+  (let
+      ((register (register-read-with-preview "Compare counter to register: ")))
+    (kmacro-reg-add-counter '< register arg)))
+
+
+(defun kmacro-reg-add-counter-greater (&optional arg)
+  "Increment counter by ARG if it is greater than register value"
+  (interactive "p")
+  (let
+      ((register (register-read-with-preview "Compare counter to register: ")))
+    (kmacro-reg-add-counter '> register arg)))
+
+
+(defun kmacro-reg-add-counter (func register &optional arg)
+  "Increment the counter by ARG if (FUNC kmacro-counter REGISTER-VALUE)
+is true.
+With no ARG, ARG is set to 1"
+  (let ((register-val (get-register register))
+        (arg (if (null arg) 1 arg)))
+    (when (apply func (list kmacro-counter register-val))
+      (setq current-prefix-arg nil)
+      (kmacro-add-counter arg))))
+
+
+(defun kmacro-quit-counter-equal (&optional arg)
+  "Quit the keyboard macro if the counter is equal to ARG"
+  (interactive "P")
+  (kmacro-quit-counter '= arg))
+
+
+(defun kmacro-quit-counter-less (&optional arg)
+  "Quit the keyboard macro if the counter is less than ARG"
+  (interactive "P")
+  (kmacro-quit-counter '< arg))
+
+
+(defun kmacro-quit-counter-greater (&optional arg)
+  "Quit the keyboard macro if the counter is greater than ARG"
+    (interactive "P")
+    (kmacro-quit-counter '> arg))
+
+
+(defun kmacro-quit-counter (func &optional arg)
+  "Quit the keyboard macro if (FUNC kmacro-counter ARG) is true.
+With \\[universal-argument] or no ARG, ARG is set to 0"
+  (when kmacro-initial-counter-value
+      (setq kmacro-counter kmacro-initial-counter-value
+	    kmacro-initial-counter-value nil))
+  (let ((arg
+	 (cond ((or (consp arg) (null arg)) 0)
+	       ((eq '- arg) -1)
+	       (t arg))))
+    (when (apply func (list kmacro-counter arg))
+      (keyboard-quit))))
+
+
 (defun kmacro-loop-setup-function ()
   "Function called prior to each iteration of macro."
   ;; Restore macro counter format to initial format, so it is ok to change

--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/test/lisp/kmacro-tests.el b/test/lisp/kmacro-tests.el
index 551fd8b60fc..e30681db539 100644
--- a/test/lisp/kmacro-tests.el
+++ b/test/lisp/kmacro-tests.el
@@ -275,6 +275,220 @@ kmacro-tests-start-insert-counter-appends-to-macro
     ;;  Verify that the recording state has changed.
     (should (equal defining-kbd-macro 'append))))
 
+
+(kmacro-tests-deftest kmacro-tests-test-reg-load ()
+  "`kmacro-reg-load-counter' loads the value of register to into the counter"
+  (set-register ?\C-r 4) ;; Should be safe as a register name
+  (kmacro-tests-simulate-command '(kmacro-set-counter 1))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              "\C-x\C-k\C-i"
+                              ;; Load from register
+                              "\C-x\C-k\C-rl\C-r"
+                              ))
+  (kmacro-tests-should-insert "1245"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 2)))
+    (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-save ()
+  "`kmacro-reg-save-counter' save the counter to a register"
+  (set-register ?\C-r nil) ;; Should be safe as a register name
+  (kmacro-tests-simulate-command '(kmacro-set-counter 1))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Save to register
+                              "\C-x\C-k\C-rs\C-r"
+                              ;; Add to counter
+                              "\C-u2\C-x\C-k\C-a"
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Insert register
+                              "\C-xri\C-r"
+                              ))
+  (kmacro-tests-should-insert "142586"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 2)))
+  (set-register ?\C-r nil))
+
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-equal-01 ()
+  "`kmacro-reg-add-counter-equal' increments counter if equal to register"
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Increment counter if it matches
+                              "\C-x\C-k\C-ra=\C-r"
+                              ))
+  (kmacro-tests-should-insert "0134"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-equal-02 ()
+  "`kmacro-reg-add-counter-equal' increments counter if equal to register"
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Add two to counter if it matches
+                              "\C-u2\C-x\C-k\C-ra=\C-r"
+                              ))
+  (kmacro-tests-should-insert "0145"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-equal-03 ()
+  "`kmacro-reg-add-counter-equal' increments counter if equal to register"
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Add four to counter if it matches
+                              "\C-u\C-x\C-k\C-ra=\C-r"
+                              ))
+  (kmacro-tests-should-insert "0167"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-equal-04 ()
+  "`kmacro-reg-add-counter-equal' increments counter if equal to register"
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Decrement counter if it matches
+                              "\C-u-\C-x\C-k\C-ra=\C-r"
+                              ))
+  (kmacro-tests-should-insert "0111"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-less ()
+  "`kmacro-reg-add-counter-less' increments counter if less than register"
+  (set-register ?\C-r 6) ;; Should be safe as a register name
+  (kmacro-tests-simulate-command '(kmacro-set-counter 8))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Decrement counter if it's
+                              ;; less than the register
+                              "\C-u-1\C-x\C-k\C-ra<\C-r"
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ))
+  (kmacro-tests-should-insert "8764"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+    (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-greater ()
+  "`kmacro-reg-add-counter-greater' increments counter if greater than register"
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Increment counter if it's greater
+                              ;; than the register
+                              "\C-x\C-k\C-ra>\C-r"
+                              ))
+  (kmacro-tests-should-insert "0124"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-equal-01 ()
+  "`kmacro-quit-counter-equal' stops macro if counter is equal to prefix"
+  (kmacro-tests-simulate-command '(kmacro-set-counter 5))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ;; Stop if the counter is at 0
+                              "\C-x\C-k\C-q="
+                              ))
+  (kmacro-tests-should-insert "5432"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 1 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-equal-02 ()
+  "`kmacro-quit-counter-equal' stops macro if counter is equal to prefix"
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Stop if the counter is at 5
+                              "\C-u5\C-x\C-k\C-q="
+                              ))
+  (kmacro-tests-should-insert "0123"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 4 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-equal-03 ()
+  "`kmacro-quit-counter-equal' stops macro if counter is equal to prefix"
+  (kmacro-tests-simulate-command '(kmacro-set-counter 5))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ;; Stop if the counter is at 0
+                              "\C-u\C-x\C-k\C-q="
+                              ))
+  (kmacro-tests-should-insert "5432"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 1 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-equal-04 ()
+  "`kmacro-quit-counter-equal' stops macro if counter is equal to prefix"
+  (kmacro-tests-simulate-command '(kmacro-set-counter 4))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ;; Stop if the counter is at -1
+                              "\C-u-\C-x\C-k\C-q="
+                              ))
+  (kmacro-tests-should-insert "4321"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 0 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-less ()
+  "`kmacro-quit-counter-less' stops macro if counter is less than prefix"
+  (kmacro-tests-simulate-command '(kmacro-set-counter 8))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Stop if the counter is less than 5
+                              "\C-u5\C-x\C-k\C-q<"
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ))
+  (kmacro-tests-should-insert "8765"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 4 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-greater ()
+  "`kmacro-quit-counter-greater' stops macro if counter is greater than prefix"
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Stop if the counter is greater than 4
+                              "\C-u4\C-x\C-k\C-q>"
+                              ))
+  (kmacro-tests-should-insert "0123"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 4 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+
 (kmacro-tests-deftest kmacro-tests-end-call-macro-prefix-args ()
   "kmacro-end-call-macro changes behavior based on prefix arg."
   ;; "Record" two macros.

--=-=-=
Content-Type: text/plain

-- 
Alex.

--=-=-=--




Message sent:


Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
Content-Type: text/plain; charset=utf-8
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Alex Bochannek <alex@HIDDEN>
Subject: bug#61549: Acknowledgement (30.0.50; [PATCH] New keyboard macro
 counter functions)
Message-ID: <handler.61549.B.16765355244710.ack <at> debbugs.gnu.org>
References: <m2a61ef2i2.fsf@HIDDEN>
X-Gnu-PR-Message: ack 61549
X-Gnu-PR-Package: emacs
X-Gnu-PR-Keywords: patch
Reply-To: 61549 <at> debbugs.gnu.org
Date: Thu, 16 Feb 2023 08:19:02 +0000

Thank you for filing a new bug report with debbugs.gnu.org.

This is an automatically generated reply to let you know your message
has been received.

Your message is being forwarded to the package maintainers and other
interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
 bug-gnu-emacs@HIDDEN

If you wish to submit further information on this problem, please
send it to 61549 <at> debbugs.gnu.org.

Please do not send mail to help-debbugs@HIDDEN unless you wish
to report a problem with the Bug-tracking system.

--=20
61549: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D61549
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Fri, 17 Feb 2023 08:14:02 +0000
Resent-Message-ID: <handler.61549.B61549.167662164024876 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 61549
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Alex Bochannek <alex@HIDDEN>, Stefan Monnier <monnier@HIDDEN>, Lars Ingebrigtsen <larsi@HIDDEN>
Cc: 61549 <at> debbugs.gnu.org
Received: via spool by 61549-submit <at> debbugs.gnu.org id=B61549.167662164024876
          (code B ref 61549); Fri, 17 Feb 2023 08:14:02 +0000
Received: (at 61549) by debbugs.gnu.org; 17 Feb 2023 08:14:00 +0000
Received: from localhost ([127.0.0.1]:38394 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSvsW-0006TA-3o
	for submit <at> debbugs.gnu.org; Fri, 17 Feb 2023 03:14:00 -0500
Received: from eggs.gnu.org ([209.51.188.92]:40532)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pSvsR-0006Sr-2A
 for 61549 <at> debbugs.gnu.org; Fri, 17 Feb 2023 03:13:58 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pSvsK-0000bL-9I; Fri, 17 Feb 2023 03:13:48 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=E3Xaz9uvOzWcbscgtVQQQgGrbmwabiY0RFnNH58xOis=; b=BrRn2S5Aeyh5
 B6BZpwms3RC6jnqxFpXMX6yBLB3rlKb4o/tQQ6RD5sBp4ImmoDa3qpvUHZFJAZuZ49BTri1yg+LTq
 jqIBw5elI7gSyMUCfohNlYYHOFAdIDaIlmEQojmV1vVgcKQ0V19vDEy9GVNXqGy2rv1X6eUTG+6DT
 XpBYjvSc8Yy6N5zwf16lBlsPk/Fo7H5iVFvhEIpqAxdGEqYt1tvOE59Yl+zOYaLN0Xl7b9nIVwT4u
 i7Jb8c2Jhw9AkEyga6XjuL5TbRUvYlHCJ1bd6IBMvaQFFF6VfniigQwa+7vT8EsA5Lo8l/hzRd3+X
 en3HcbRC9zEfnak2OUUE0Q==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pSvsJ-0006cK-MH; Fri, 17 Feb 2023 03:13:48 -0500
Date: Fri, 17 Feb 2023 10:13:45 +0200
Message-Id: <83sff41zgm.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <m2a61ef2i2.fsf@HIDDEN> (message from Alex Bochannek on
 Thu, 16 Feb 2023 00:17:25 -0800)
References: <m2a61ef2i2.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Alex Bochannek <alex@HIDDEN>
> Date: Thu, 16 Feb 2023 00:17:25 -0800
> 
> I have been working on blog posts about keyboard macros and found that
> it would be useful to have comparison functions for the keyboard macro
> counter.

Thanks.

> I implemented two functions to load and save macro counter values from
> and to number registers; three comparison functions of the macro counter
> with a number register that conditionally increment the counter; three
> comparison functions of the macro counter with a prefix that terminate
> the macro execution. This simplifies handling multiple counters and
> conditional macro termination.
> 
> I am attaching the changes to:
>   emacs.texi
>   kmacro.texi
>   NEWS
>   kmacro.el
>   kmacro-tests.el
> 
> I hope this functionality is useful and that I followed the coding and
> style standards.

I wonder whether these commands are important enough to have them in
the manual.  Stefan and Lars, WDYT?  Any other comments to the feature
and its implementation?

> +(defun kmacro-reg-load-counter (register)
> +  "Load the value of a register into `kmacro-counter'"

The first line of a doc string should be a single complete sentence,
ending with a period (here and elsewhere).  You may wish running
checkdoc on your code to reveal any issues.

> +(defun kmacro-reg-add-counter-equal (&optional arg)
> +  "Increment counter by ARG if it is equal to register value"

This doc string is confusing, I think.  Would you like to reword it to
clarify whet the command does?  In particular, the "it" part is
ambiguous.

> +(defun kmacro-reg-add-counter-less (&optional arg)
> +  "Increment counter by ARG if it is less than register value"
> +  (interactive "p")
> +  (let
> +      ((register (register-read-with-preview "Compare counter to register: ")))
> +    (kmacro-reg-add-counter '< register arg)))
> +
> +
> +(defun kmacro-reg-add-counter-greater (&optional arg)
> +  "Increment counter by ARG if it is greater than register value"
> +  (interactive "p")
> +  (let
> +      ((register (register-read-with-preview "Compare counter to register: ")))
> +    (kmacro-reg-add-counter '> register arg)))

Similar problems with the doc strings of these two commands.

> +(defun kmacro-reg-add-counter (func register &optional arg)
> +  "Increment the counter by ARG if (FUNC kmacro-counter REGISTER-VALUE)
> +is true.
> +With no ARG, ARG is set to 1"

Our style is to say "ARG is the numeric prefix argument that defaults
to 1."

> +(defun kmacro-quit-counter-equal (&optional arg)
> +  "Quit the keyboard macro if the counter is equal to ARG"

"when the counter is equal to ARG", I guess?

> +(defun kmacro-quit-counter-less (&optional arg)
> +  "Quit the keyboard macro if the counter is less than ARG"
> +  (interactive "P")
> +  (kmacro-quit-counter '< arg))
> +
> +
> +(defun kmacro-quit-counter-greater (&optional arg)
> +  "Quit the keyboard macro if the counter is greater than ARG"
> +    (interactive "P")
> +    (kmacro-quit-counter '> arg))

Likewise here.

> +(defun kmacro-quit-counter (func &optional arg)
> +  "Quit the keyboard macro if (FUNC kmacro-counter ARG) is true.

Our style is to use PRED instead of FUNC, and document like this:

    Quit the keyboard macro when predicate PRED returns non-nil.
  PRED is called with two arguments: kmacro-counter and ARG.

> +With \\[universal-argument] or no ARG, ARG is set to 0"

  "Arg is the prefix numeric argument and defaults to zero."

> +  (let ((arg
> +	 (cond ((or (consp arg) (null arg)) 0)
> +	       ((eq '- arg) -1)
> +	       (t arg))))

This seems to imply that ARG has meaning beyond what the above text
says.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions
Resent-From: Alex Bochannek <alex@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sun, 19 Feb 2023 02:00:02 +0000
Resent-Message-ID: <handler.61549.B61549.16767719617010 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 61549
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Eli Zaretskii <eliz@HIDDEN>
Cc: Lars Ingebrigtsen <larsi@HIDDEN>, Stefan Monnier <monnier@HIDDEN>, 61549 <at> debbugs.gnu.org
Received: via spool by 61549-submit <at> debbugs.gnu.org id=B61549.16767719617010
          (code B ref 61549); Sun, 19 Feb 2023 02:00:02 +0000
Received: (at 61549) by debbugs.gnu.org; 19 Feb 2023 01:59:21 +0000
Received: from localhost ([127.0.0.1]:45275 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pTYz3-0001oy-EM
	for submit <at> debbugs.gnu.org; Sat, 18 Feb 2023 20:59:21 -0500
Received: from ns.lapseofthought.com ([50.0.39.240]:60085
 helo=mail.lapseofthought.com)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <alex@HIDDEN>) id 1pTYz1-0001op-97
 for 61549 <at> debbugs.gnu.org; Sat, 18 Feb 2023 20:59:20 -0500
Received: from awb-mbp.local (c-73-92-249-246.hsd1.ca.comcast.net
 [73.92.249.246])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by mail.lapseofthought.com (Postfix) with ESMTPSA id 4PK7yX0sK5z3pdxK;
 Sat, 18 Feb 2023 17:59:16 -0800 (PST)
Authentication-Results: ORIGINATING;
 auth=pass smtp.auth=alex smtp.mailfrom=alex@HIDDEN
From: Alex Bochannek <alex@HIDDEN>
In-Reply-To: <83sff41zgm.fsf@HIDDEN> (Eli Zaretskii's message of "Fri, 17 Feb
 2023 10:13:45 +0200")
References: <m2a61ef2i2.fsf@HIDDEN> <83sff41zgm.fsf@HIDDEN>
Date: Sat, 18 Feb 2023 17:59:15 -0800
Message-ID: <m2lekuo1os.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli,

Thanks for all the doc string comments, I was not sure about them and I
don't think I knew about checkdoc. I should spend some more time with
Appendix D of the Elisp manual.

Eli Zaretskii <eliz@HIDDEN> writes:

>> +  (let ((arg
>> +	 (cond ((or (consp arg) (null arg)) 0)
>> +	       ((eq '- arg) -1)
>> +	       (t arg))))
>
> This seems to imply that ARG has meaning beyond what the above text
> says.

I was struggling a bit with this one. On the one hand, I wanted the raw
prefix because I didn't want `C-u' to turn into 4, on the other hand, I
still wanted to let `C-u -' be interpreted as -1. Is there a better way
to do this?

I am updating the doc strings and submit a new version in the next few
days.

Thanks for the review!

-- 
Alex.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sun, 19 Feb 2023 06:55:02 +0000
Resent-Message-ID: <handler.61549.B61549.16767896795995 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 61549
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Alex Bochannek <alex@HIDDEN>
Cc: larsi@HIDDEN, monnier@HIDDEN, 61549 <at> debbugs.gnu.org
Received: via spool by 61549-submit <at> debbugs.gnu.org id=B61549.16767896795995
          (code B ref 61549); Sun, 19 Feb 2023 06:55:02 +0000
Received: (at 61549) by debbugs.gnu.org; 19 Feb 2023 06:54:39 +0000
Received: from localhost ([127.0.0.1]:45518 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pTdap-0001Yd-1F
	for submit <at> debbugs.gnu.org; Sun, 19 Feb 2023 01:54:39 -0500
Received: from eggs.gnu.org ([209.51.188.92]:43380)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pTdam-0001YN-FW
 for 61549 <at> debbugs.gnu.org; Sun, 19 Feb 2023 01:54:37 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pTdaf-0000WV-Vd; Sun, 19 Feb 2023 01:54:29 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=cWYT632w7IWvQ1byClzrfK3niYeArufGQWvxDVkjctA=; b=MUxBmh4VUGjH
 ZX1vOCW2AeOYyAmolLAIqs+d3Uk+rL8c//0XitOrdVlU3dBysAX0+guUCNFrhiO9AtxXsTHsi4khZ
 aiU17ZByIy9J3SQmscopFXN9LRnG5TYMSF/trH1jelWRyhx1ecSGOrCTLFzYyCJLoZK/UjFDJ3oy/
 7rnE16AhLZPce+PYLL0eIlOmHDnwS+L5NqF5dqrXmoXbGxNAr3flEgiY1x+MSST3wv+c24+oLTVoT
 SaZVmHaVMbX1ytx2tX2o4JMlFdMknyVPB72hoOB+WVGx2XJRdnPv36TvSWBEpvHr4wzCnAbHDZc3i
 WbYSlo3AiuHwYyM0mdJ47Q==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pTdaf-0001BG-AH; Sun, 19 Feb 2023 01:54:29 -0500
Date: Sun, 19 Feb 2023 08:54:34 +0200
Message-Id: <83fsb2xhzp.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <m2lekuo1os.fsf@HIDDEN> (message from Alex Bochannek on
 Sat, 18 Feb 2023 17:59:15 -0800)
References: <m2a61ef2i2.fsf@HIDDEN> <83sff41zgm.fsf@HIDDEN>
 <m2lekuo1os.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Alex Bochannek <alex@HIDDEN>
> Cc: Stefan Monnier <monnier@HIDDEN>,  Lars Ingebrigtsen
>  <larsi@HIDDEN>,  61549 <at> debbugs.gnu.org
> Date: Sat, 18 Feb 2023 17:59:15 -0800
> 
> >> +  (let ((arg
> >> +	 (cond ((or (consp arg) (null arg)) 0)
> >> +	       ((eq '- arg) -1)
> >> +	       (t arg))))
> >
> > This seems to imply that ARG has meaning beyond what the above text
> > says.
> 
> I was struggling a bit with this one. On the one hand, I wanted the raw
> prefix because I didn't want `C-u' to turn into 4, on the other hand, I
> still wanted to let `C-u -' be interpreted as -1. Is there a better way
> to do this?

Why do you want C-u to be equivalent to "C-u 0"?  That's inconsistent,
and you already provide an easy way of supplying zero: by using no
prefix argument at all.

In any case, what I meant was that the processing is incompletely
described by the documentation.  And the documentation about the
effect of the prefix argument should be in the doc strings of the
commands, not in the doc string of this function, which is not
intended for interactive use.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions
Resent-From: Alex Bochannek <alex@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Mon, 06 Mar 2023 03:38:02 +0000
Resent-Message-ID: <handler.61549.B61549.167807385117683 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 61549
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Eli Zaretskii <eliz@HIDDEN>
Cc: larsi@HIDDEN, monnier@HIDDEN, 61549 <at> debbugs.gnu.org
Received: via spool by 61549-submit <at> debbugs.gnu.org id=B61549.167807385117683
          (code B ref 61549); Mon, 06 Mar 2023 03:38:02 +0000
Received: (at 61549) by debbugs.gnu.org; 6 Mar 2023 03:37:31 +0000
Received: from localhost ([127.0.0.1]:41061 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pZ1fG-0004b8-By
	for submit <at> debbugs.gnu.org; Sun, 05 Mar 2023 22:37:31 -0500
Received: from ns.lapseofthought.com ([50.0.39.240]:61400
 helo=mail.lapseofthought.com)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <alex@HIDDEN>) id 1pZ1fC-0004ay-Dx
 for 61549 <at> debbugs.gnu.org; Sun, 05 Mar 2023 22:37:28 -0500
Received: from awb-mbp.local (c-73-92-249-246.hsd1.ca.comcast.net
 [73.92.249.246])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by mail.lapseofthought.com (Postfix) with ESMTPSA id 4PVPQp3N0Wz3pqNH;
 Sun,  5 Mar 2023 19:37:22 -0800 (PST)
Authentication-Results: ORIGINATING;
 auth=pass smtp.auth=alex smtp.mailfrom=alex@HIDDEN
From: Alex Bochannek <alex@HIDDEN>
In-Reply-To: <83fsb2xhzp.fsf@HIDDEN> (Eli Zaretskii's message of "Sun, 19 Feb
 2023 08:54:34 +0200")
References: <m2a61ef2i2.fsf@HIDDEN> <83sff41zgm.fsf@HIDDEN>
 <m2lekuo1os.fsf@HIDDEN> <83fsb2xhzp.fsf@HIDDEN>
Date: Sun, 05 Mar 2023 19:37:21 -0800
Message-ID: <m2a60qwnwu.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain

Eli,

Took me a little bit longer to find time to do this and I now have
incorporated your feedback in the below patch. Thank you for your
perspective on prefix, that made a lot of sense and I reworked that part
of the code to be consistent with how it usually works. I was not aware
that the interactive code `p' defaults to 1 in the absence of a prefix.
I couldn't find a place where this is documented and it simplified the
code.

I updated the docstrings as you suggested and even though checkdoc
complained about the lack of a period on the first line, I figured it's
better to keep below the line length limits.

Let me know if you would like to see any other changes, I always
appreciate constructive feedback!

I am attaching the changes to:
  kmacro.texi
  kmacro.el
  kmacro-tests.el

The changelog as well as NEWS and emacs.texi remain the same from my
original message.


--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/doc/emacs/kmacro.texi b/doc/emacs/kmacro.texi
index fc1402b489d..c3d74bb39ed 100644
--- a/doc/emacs/kmacro.texi
+++ b/doc/emacs/kmacro.texi
@@ -35,6 +35,7 @@ Keyboard Macros
 * Basic Keyboard Macro::     Defining and running keyboard macros.
 * Keyboard Macro Ring::      Where previous keyboard macros are saved.
 * Keyboard Macro Counter::   Inserting incrementing numbers in macros.
+* Advanced Macro Counter::   Advanced macro counter commands.
 * Keyboard Macro Query::     Making keyboard macros do different things each
                                time.
 * Save Keyboard Macro::      Giving keyboard macros names; saving them in
@@ -364,6 +365,123 @@ Keyboard Macro Counter
 keyboard macro counter.  @xref{Number Registers}.  For most purposes,
 it is simpler to use a keyboard macro counter.
 
+@node Advanced Macro Counter
+@section Advanced Macro Counter Commands
+
+  The counter associated with a keyboard macro is sufficient in most
+cases.  If additional counters are required for a macro, registers can
+be used and these advanced macro counter commands simplify the
+interaction between the two.  Additional commands are provided to
+terminate a macro after a predefined number of runs.
+
+
+@table @kbd
+@item C-x C-k C-r l
+Load the value of a number register into the macro counter
+(@code{kmacro-reg-load-counter}).
+@item C-x C-k C-r s
+Save the value of the macro counter to a number register
+(@code{kmacro-reg-save-counter}).
+@end table
+
+@table @kbd
+@item C-x C-k C-r a =
+Compare if the macro counter is equal to the value of a register and
+increment the counter if it is (@code{kmacro-reg-add-counter-equal}).
+@item C-x C-k C-r a <
+Compare if the macro counter is less than the value of a register and
+increment the counter if it is (@code{kmacro-reg-add-counter-less}).
+@item C-x C-k C-r a >
+Compare if the macro counter is greater than the value of a register
+and increment the counter if it is
+(@code{kmacro-reg-add-counter-greater}).
+@end table
+
+@table @kbd
+@item C-x C-k C-q =
+Compare if the macro counter is equal to the prefix and terminate the
+macro if it is (@code{kmacro-quit-counter-equal}).
+@item C-x C-k C-q <
+Compare if the macro counter is less than the prefix and terminate the
+macro if it is (@code{kmacro-quit-counter-less}).
+@item C-x C-k C-q >
+Compare if the macro counter is greater than the prefix and terminate
+the macro if it is (@code{kmacro-quit-counter-greater}).
+@end table
+
+@findex kmacro-reg-load-counter
+@kindex C-x C-k C-r l
+@findex kmacro-reg-save-counter
+@kindex C-x C-k C-r s
+  The command @kbd{C-x C-k C-r l} (@code{kmacro-reg-load-counter})
+prompts for the register name from which to load a number into the
+macro counter.  The command @kbd{C-x C-k C-r s}
+(@code{kmacro-reg-save-counter}) prompts for the register name into
+which to save the macro counter's value.  Both @kbd{C-x C-k C-r l}
+(@code{kmacro-reg-load-counter}) and @kbd{C-x C-k C-r s}
+(@code{kmacro-reg-save-counter}) show a preview of the registers by
+default.  @xref{Registers}.  Both commands can be used during or
+outside a keyboard macro definition.
+
+@findex kmacro-reg-add-counter-equal
+@kindex C-x C-k C-r a =
+@findex kmacro-reg-add-counter-less
+@kindex C-x C-k C-r a <
+@findex kmacro-reg-add-counter-greater
+@kindex C-x C-k C-r a >
+  The @kbd{C-x C-k C-r a =} (@code{kmacro-reg-add-counter-equal}),
+@kbd{C-x C-k C-r a <} (@code{kmacro-reg-add-counter-less}), and
+@kbd{C-x C-k C-r a >} (@code{kmacro-reg-add-counter-greater}) commands
+all follow the same pattern.  During keyboard macro definition, the
+command prompts for a register name (with preview by default), the
+contents of which will be compared with the macro counter's value.  If
+the counter is equal to (@code{=}), less than (@code{<}), or greater
+than (@code{>}) the number register's contents, the counter will be
+incremented by the numeric prefix or one if no prefix was given to the
+command.
+
+  For example,
+
+@example
+C-u 2 C-x C-k C-r a > N
+@end example
+
+@noindent
+compares the counter with the contents of register @code{N} and if the
+counter is greater than that, increases it by two.
+
+@findex kmacro-quit-counter-equal
+@kindex C-x C-k C-q =
+@findex kmacro-quit-counter-less
+@kindex C-x C-k C-q <
+@findex kmacro-quit-counter-greater
+@kindex C-x C-k C-q >
+  Finally, the @kbd{C-x C-k C-q =} (@code{kmacro-quit-counter-equal}),
+@kbd{C-x C-k C-q <} (@code{kmacro-quit-counter-less}), and @kbd{C-x
+C-k C-q >} (@code{kmacro-quit-counter-greater}) commands compare the
+macro counter with the prefix given and terminate the execution of the
+macro, if the comparison succeeds.  If no numeric prefix is given, the
+counter will be compared with zero.  The macro is terminated using the
+@code{keyboard-quit} function.  Using this command to exit from a
+macro that has been called by another macro is not supported, the
+entire executing macro is terminated.
+
+  The quit commands can be used to construct the equivalent of a
+@code{while}-loop. This example will stop after ten executions
+assuming the starting value for the macro counter is the default zero.
+
+@example
+C-u 10 C-x C-k C-q = C-x C-k C-i @key{RET}
+@end example
+
+  With the default counter value of zero, the macro called with a
+prefix of @code{C-u C-u} to execute sixteen times, will stop after ten
+iterations.  The counter values that have been inserted will be from 0
+to 9.  If the counter starts out a different value below ten, it will
+still stop at ten, because the counter does not actually count macro
+executions, but is incremented explicitly by the @code{C-x C-k C-i}
+command.
+
 @node Keyboard Macro Query
 @section Executing Macros with Variations
 

--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/lisp/kmacro.el b/lisp/kmacro.el
index 94d8794bd23..d0630a1998f 100644
--- a/lisp/kmacro.el
+++ b/lisp/kmacro.el
@@ -183,10 +183,18 @@ kmacro-keymap
   "C-l"  #'kmacro-call-ring-2nd-repeat
 
   ;; macro counter
-  "C-f"  #'kmacro-set-format
-  "C-c"  #'kmacro-set-counter
-  "C-i"  #'kmacro-insert-counter
-  "C-a"  #'kmacro-add-counter
+  "C-f"     #'kmacro-set-format
+  "C-c"     #'kmacro-set-counter
+  "C-i"     #'kmacro-insert-counter
+  "C-a"     #'kmacro-add-counter
+  "C-r l"   #'kmacro-reg-load-counter
+  "C-r s"   #'kmacro-reg-save-counter
+  "C-r a =" #'kmacro-reg-add-counter-equal
+  "C-r a <" #'kmacro-reg-add-counter-less
+  "C-r a >" #'kmacro-reg-add-counter-greater
+  "C-q ="   #'kmacro-quit-counter-equal
+  "C-q <"   #'kmacro-quit-counter-less
+  "C-q >"   #'kmacro-quit-counter-greater
 
   ;; macro editing
   "C-e"  #'kmacro-edit-macro-repeat
@@ -347,6 +355,96 @@ kmacro-add-counter
     (kmacro-display-counter)))
 
 
+(defun kmacro-reg-load-counter (register)
+  "Load the value of REGISTER into `kmacro-counter'."
+  (interactive
+   (list (register-read-with-preview "Load register to counter: ")))
+  (let ((register-val (get-register register)))
+    (when (numberp register-val)
+     (setq kmacro-counter register-val))))
+
+
+(defun kmacro-reg-save-counter (register)
+  "Save the value of `kmacro-counter' to REGISTER."
+  (interactive
+   (list (register-read-with-preview "Save counter to register: ")))
+  (set-register register kmacro-counter))
+
+
+(defun kmacro-reg-add-counter-equal (&optional arg)
+  "Increment `kmacro-counter' by ARG if the counter is equal to a
+register's value.
+ARG is the numeric prefix argument that defaults to one."
+  (interactive "p")
+  (let
+      ((register (register-read-with-preview "Compare counter to register: ")))
+    (kmacro-reg-add-counter '= register arg)))
+
+
+(defun kmacro-reg-add-counter-less (&optional arg)
+  "Increment `kmacro-counter' by ARG if the counter is less than a
+register's value.
+ARG is the numeric prefix argument that defaults to one."
+  (interactive "p")
+  (let
+      ((register (register-read-with-preview "Compare counter to register: ")))
+    (kmacro-reg-add-counter '< register arg)))
+
+
+(defun kmacro-reg-add-counter-greater (&optional arg)
+  "Increment `kmacro-counter' by ARG if the counter is greater than
+a register's value.
+ARG is the numeric prefix argument that defaults to one."
+  (interactive "p")
+  (let
+      ((register (register-read-with-preview "Compare counter to register: ")))
+    (kmacro-reg-add-counter '> register arg)))
+
+
+(defun kmacro-reg-add-counter (pred register arg)
+  "Increment `kmacro-counter' by ARG if predicate PRED returns
+non-nil.
+PRED is called with two arguments: `kmacro-counter' and REGISTER."
+  (let ((register-val (get-register register)))
+    (when (apply pred (list kmacro-counter register-val))
+      (setq current-prefix-arg nil)
+      (kmacro-add-counter arg))))
+
+
+(defun kmacro-quit-counter-equal (&optional arg)
+  "Quit the keyboard macro if `kmacro-counter' is equal to ARG.
+ARG is the numeric prefix argument that defaults to zero."
+  (interactive "P")
+  (kmacro-quit-counter '= arg))
+
+
+(defun kmacro-quit-counter-less (&optional arg)
+  "Quit the keyboard macro if `kmacro-counter' is less than ARG.
+ARG is the numeric prefix argument that defaults to zero."
+  (interactive "P")
+  (kmacro-quit-counter '< arg))
+
+
+(defun kmacro-quit-counter-greater (&optional arg)
+  "Quit the keyboard macro if `kmacro-counter' is greater than ARG.
+ARG is the numeric prefix argument that defaults to zero."
+    (interactive "P")
+    (kmacro-quit-counter '> arg))
+
+
+(defun kmacro-quit-counter (pred &optional arg)
+  "Quit the keyboard macro if predicate PRED returns non-nil.
+PRED is called with two arguments: `kmacro-counter' and ARG."
+  (when kmacro-initial-counter-value
+    (setq kmacro-counter kmacro-initial-counter-value
+	  kmacro-initial-counter-value nil))
+  (let ((arg
+	 (cond ((null arg) 0)
+	       (t (prefix-numeric-value arg)))))
+    (when (apply pred (list kmacro-counter arg))
+      (keyboard-quit))))
+
+
 (defun kmacro-loop-setup-function ()
   "Function called prior to each iteration of macro."
   ;; Restore macro counter format to initial format, so it is ok to change

--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/test/lisp/kmacro-tests.el b/test/lisp/kmacro-tests.el
index 551fd8b60fc..42ada9f4f94 100644
--- a/test/lisp/kmacro-tests.el
+++ b/test/lisp/kmacro-tests.el
@@ -275,6 +275,205 @@ kmacro-tests-start-insert-counter-appends-to-macro
     ;;  Verify that the recording state has changed.
     (should (equal defining-kbd-macro 'append))))
 
+
+(kmacro-tests-deftest kmacro-tests-test-reg-load ()
+  "`kmacro-reg-load-counter' loads the value of register into counter"
+  (set-register ?\C-r 4) ;; Should be safe as a register name
+  (kmacro-tests-simulate-command '(kmacro-set-counter 1))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              "\C-x\C-k\C-i"
+                              ;; Load from register
+                              "\C-x\C-k\C-rl\C-r"
+                              ))
+  (kmacro-tests-should-insert "1245"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 2)))
+    (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-save ()
+  "`kmacro-reg-save-counter' saves counter to register"
+  (set-register ?\C-r nil) ;; Should be safe as a register name
+  (kmacro-tests-simulate-command '(kmacro-set-counter 1))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Save to register
+                              "\C-x\C-k\C-rs\C-r"
+                              ;; Add to counter
+                              "\C-u2\C-x\C-k\C-a"
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Insert register
+                              "\C-xri\C-r"
+                              ))
+  (kmacro-tests-should-insert "142586"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 2)))
+  (set-register ?\C-r nil))
+
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-equal-01 ()
+  "`kmacro-reg-add-counter-equal' increments counter if equal to register"
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Increment counter if it matches
+                              "\C-x\C-k\C-ra=\C-r"
+                              ))
+  (kmacro-tests-should-insert "0134"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-equal-02 ()
+  "`kmacro-reg-add-counter-equal' increments counter if equal to register"
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Add two to counter if it matches
+                              "\C-u2\C-x\C-k\C-ra=\C-r"
+                              ))
+  (kmacro-tests-should-insert "0145"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-equal-03 ()
+  "`kmacro-reg-add-counter-equal' increments counter if equal to register"
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Add four to counter if it matches
+                              "\C-u\C-x\C-k\C-ra=\C-r"
+                              ))
+  (kmacro-tests-should-insert "0167"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-equal-04 ()
+  "`kmacro-reg-add-counter-equal' increments counter if equal to register"
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Decrement counter if it matches
+                              "\C-u-\C-x\C-k\C-ra=\C-r"
+                              ))
+  (kmacro-tests-should-insert "0111"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-less ()
+  "`kmacro-reg-add-counter-less' increments counter if less than register"
+  (set-register ?\C-r 6) ;; Should be safe as a register name
+  (kmacro-tests-simulate-command '(kmacro-set-counter 8))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Decrement counter if it's
+                              ;; less than the register
+                              "\C-u-1\C-x\C-k\C-ra<\C-r"
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ))
+  (kmacro-tests-should-insert "8764"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+    (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-greater ()
+  "`kmacro-reg-add-counter-greater' increments counter if greater than register"
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Increment counter if it's greater
+                              ;; than the register
+                              "\C-x\C-k\C-ra>\C-r"
+                              ))
+  (kmacro-tests-should-insert "0124"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-equal-01 ()
+  "`kmacro-quit-counter-equal' stops macro if counter is equal to prefix"
+  (kmacro-tests-simulate-command '(kmacro-set-counter 5))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ;; Stop if the counter is at 0
+                              "\C-x\C-k\C-q="
+                              ))
+  (kmacro-tests-should-insert "5432"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 1 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-equal-02 ()
+  "`kmacro-quit-counter-equal' stops macro if counter is equal to prefix"
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Stop if the counter is at 5
+                              "\C-u5\C-x\C-k\C-q="
+                              ))
+  (kmacro-tests-should-insert "0123"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 4 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-equal-03 ()
+  "`kmacro-quit-counter-equal' stops macro if counter is equal to prefix"
+  (kmacro-tests-simulate-command '(kmacro-set-counter 4))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ;; Stop if the counter is at -1
+                              "\C-u-\C-x\C-k\C-q="
+                              ))
+  (kmacro-tests-should-insert "4321"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 0 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-less ()
+  "`kmacro-quit-counter-less' stops macro if counter is less than prefix"
+  (kmacro-tests-simulate-command '(kmacro-set-counter 8))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Stop if the counter is less than 5
+                              "\C-u5\C-x\C-k\C-q<"
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ))
+  (kmacro-tests-should-insert "8765"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 4 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-greater ()
+  "`kmacro-quit-counter-greater' stops macro if counter is greater than prefix"
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Stop if the counter is greater than 4
+                              "\C-u4\C-x\C-k\C-q>"
+                              ))
+  (kmacro-tests-should-insert "0123"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 4 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+
 (kmacro-tests-deftest kmacro-tests-end-call-macro-prefix-args ()
   "kmacro-end-call-macro changes behavior based on prefix arg."
   ;; "Record" two macros.

--=-=-=
Content-Type: text/plain


Thanks!

-- 
Alex.

--=-=-=--




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 11 Mar 2023 08:50:01 +0000
Resent-Message-ID: <handler.61549.B61549.167852459325263 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 61549
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Alex Bochannek <alex@HIDDEN>
Cc: larsi@HIDDEN, monnier@HIDDEN, 61549 <at> debbugs.gnu.org
Received: via spool by 61549-submit <at> debbugs.gnu.org id=B61549.167852459325263
          (code B ref 61549); Sat, 11 Mar 2023 08:50:01 +0000
Received: (at 61549) by debbugs.gnu.org; 11 Mar 2023 08:49:53 +0000
Received: from localhost ([127.0.0.1]:56514 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pauvI-0006ZM-D7
	for submit <at> debbugs.gnu.org; Sat, 11 Mar 2023 03:49:52 -0500
Received: from eggs.gnu.org ([209.51.188.92]:48704)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pauvF-0006Z9-Td
 for 61549 <at> debbugs.gnu.org; Sat, 11 Mar 2023 03:49:50 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pauv9-0005K0-Qw; Sat, 11 Mar 2023 03:49:43 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=356889eT8IXMLwUMkGT87udLLQRRjdz6FX8Z0KzZDV8=; b=n4oSl+yPQhTw
 VuWQMTmbNQXbzIbE74ez49h/TZQBUaXwQUOYOcFIFvUOvGgX3M+g9vacOzTfiQ6Po1gVc8rkIiYPP
 GW5laZmos2GwWQQx1XtnJplZwvU2VAFoJ7rb/NYBRFb4FqXWFFanpkr9ys8P+zIHvtLwn/5wK6+qz
 V4cCU69aInupoLMWlFNUfeHnUF9VvTRByDx171vE0a4IKglvZGpZ1ohFtettIXwy/kGnV2nceSEC5
 rFW2lKkQk2Dz9nOUt369CiWsOtKWL9A/dRHFFw/p8smMPUYVLby+pH6O4kTaSQtcMNcmXgof/vtFr
 8DK/3BCr2i19x4evZK7gLQ==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pauv8-0006dZ-Rv; Sat, 11 Mar 2023 03:49:43 -0500
Date: Sat, 11 Mar 2023 10:49:27 +0200
Message-Id: <835yb7y8o8.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <m2a60qwnwu.fsf@HIDDEN> (message from Alex Bochannek on
 Sun, 05 Mar 2023 19:37:21 -0800)
References: <m2a61ef2i2.fsf@HIDDEN> <83sff41zgm.fsf@HIDDEN>
 <m2lekuo1os.fsf@HIDDEN> <83fsb2xhzp.fsf@HIDDEN>
 <m2a60qwnwu.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Alex Bochannek <alex@HIDDEN>
> Cc: monnier@HIDDEN,  larsi@HIDDEN,  61549 <at> debbugs.gnu.org
> Date: Sun, 05 Mar 2023 19:37:21 -0800
> 
> Took me a little bit longer to find time to do this and I now have
> incorporated your feedback in the below patch. Thank you for your
> perspective on prefix, that made a lot of sense and I reworked that part
> of the code to be consistent with how it usually works. I was not aware
> that the interactive code `p' defaults to 1 in the absence of a prefix.
> I couldn't find a place where this is documented and it simplified the
> code.
> 
> I updated the docstrings as you suggested and even though checkdoc
> complained about the lack of a period on the first line, I figured it's
> better to keep below the line length limits.

Thanks, a few more comments below.

> Let me know if you would like to see any other changes, I always
> appreciate constructive feedback!
> 
> I am attaching the changes to:
>   kmacro.texi
>   kmacro.el
>   kmacro-tests.el
> 
> The changelog as well as NEWS and emacs.texi remain the same from my
> original message.

Stefan and Lars didn't respond, and I tend to think there's no need to
describe these functions in the Emacs user manual.  So for the next
iteration (which hopefully will be the last), please submit the patch
without the changes in the manual.  Also, please post all of the
other changes, including NEWS and the commit log message (and mention
the bug number in the latter).

> +(defun kmacro-reg-add-counter-equal (&optional arg)
> +  "Increment `kmacro-counter' by ARG if the counter is equal to a
> +register's value.

The first line of a doc string must be a complete sentence.

> +(defun kmacro-reg-add-counter-less (&optional arg)
> +  "Increment `kmacro-counter' by ARG if the counter is less than a
> +register's value.

Likewise here (and elsewhere in the patch).

> +ARG is the numeric prefix argument that defaults to one."
> +  (interactive "p")
> +  (let
> +      ((register (register-read-with-preview "Compare counter to register: ")))
> +    (kmacro-reg-add-counter '< register arg)))
> +
> +
> +(defun kmacro-reg-add-counter-greater (&optional arg)

I noticed that you always leave 2 empty lines between functions.  Is
that intentional?  We generally leave just one empty line.

> +(defun kmacro-reg-add-counter (pred register arg)
> +  "Increment `kmacro-counter' by ARG if predicate PRED returns
> +non-nil.
> +PRED is called with two arguments: `kmacro-counter' and REGISTER."
> +  (let ((register-val (get-register register)))
> +    (when (apply pred (list kmacro-counter register-val))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
To avoid consing a list here, would it be better to use funcall
instead of apply here?

> +(defun kmacro-quit-counter (pred &optional arg)
> +  "Quit the keyboard macro if predicate PRED returns non-nil.
> +PRED is called with two arguments: `kmacro-counter' and ARG."
> +  (when kmacro-initial-counter-value
> +    (setq kmacro-counter kmacro-initial-counter-value
> +	  kmacro-initial-counter-value nil))
> +  (let ((arg
> +	 (cond ((null arg) 0)
> +	       (t (prefix-numeric-value arg)))))
> +    (when (apply pred (list kmacro-counter arg))
> +      (keyboard-quit))))

Likewise here.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions
Resent-From: Michael Heerdegen <michael_heerdegen@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sun, 12 Mar 2023 00:20:02 +0000
Resent-Message-ID: <handler.61549.B61549.167858036418826 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 61549
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Alex Bochannek <alex@HIDDEN>
Cc: Eli Zaretskii <eliz@HIDDEN>, larsi@HIDDEN, 61549 <at> debbugs.gnu.org, monnier@HIDDEN
Received: via spool by 61549-submit <at> debbugs.gnu.org id=B61549.167858036418826
          (code B ref 61549); Sun, 12 Mar 2023 00:20:02 +0000
Received: (at 61549) by debbugs.gnu.org; 12 Mar 2023 00:19:24 +0000
Received: from localhost ([127.0.0.1]:58830 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pb9Qp-0004tZ-VK
	for submit <at> debbugs.gnu.org; Sat, 11 Mar 2023 19:19:24 -0500
Received: from mout.web.de ([212.227.15.4]:60653)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <michael_heerdegen@HIDDEN>) id 1pb9Ql-0004tI-Ju
 for 61549 <at> debbugs.gnu.org; Sat, 11 Mar 2023 19:19:22 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=s29768273;
 t=1678580347; i=michael_heerdegen@HIDDEN;
 bh=ixchzx4guvpMvqgGghwMM/Ha/YlJtrku5g9b6nWS4nw=;
 h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date;
 b=BYFgTWnbXYQvQ7XaSMUwpHTs6rgQpsIgnGFjZhmCjINY9ToZgPZExIL18QJy2vGKZ
 kgUVANf/hstBhETyaylH34VA/FkaMyYlsoGWZoZnOlpjacZUrXCJg91rIUAhOQBrGU
 nBDw5OXTsVbB41bnrtaxzJfDr1bA4x8zQhhX04jrhOP1aEVKtcxUJUr1CbZWrIbaZS
 YiRibB7580GgOX/Lwqdt3jjSj4z8QzKUo+BtRRmYJQmHXfRsM8VRKSLao2ryeeRLbA
 Poy1hoymVrelKevOdtmf5619GJ60agNKAL4Mj6p2O2q1PLpeB9HopwzQD9uxoTj+Ii
 0YBL6DXdqYBjA==
X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6
Received: from drachen.dragon ([178.14.74.115]) by smtp.web.de (mrweb005
 [213.165.67.108]) with ESMTPSA (Nemesis) id 1N5CUb-1qZcOk2KZh-011BIz; Sun, 12
 Mar 2023 01:19:07 +0100
From: Michael Heerdegen <michael_heerdegen@HIDDEN>
In-Reply-To: <m2a60qwnwu.fsf@HIDDEN> (Alex Bochannek's message of "Sun, 
 05 Mar 2023 19:37:21 -0800")
References: <m2a61ef2i2.fsf@HIDDEN> <83sff41zgm.fsf@HIDDEN>
 <m2lekuo1os.fsf@HIDDEN> <83fsb2xhzp.fsf@HIDDEN>
 <m2a60qwnwu.fsf@HIDDEN>
Date: Sun, 12 Mar 2023 01:19:01 +0100
Message-ID: <87o7oyizyi.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Provags-ID: V03:K1:fGYHdUCm2WMBIRkST97Cd1v449JzfTS7l7BDjfsk3hQtMmqbyHI
 UKE18HqwSPNdh2M4a0v9oPTaI8CS+sK6Eil5XtsiHMoCzqcVuL37CgGx7gNVU8wKdNQS1gA
 xBe+KIojoXrlg13a4C7hAuQNgXzoMZOxBgdj2z1uEdkbILsnx995EOblzSqzUNuMPIUaR/p
 pTXxsRSXUw21dBQFmxKlw==
X-Spam-Flag: NO
UI-OutboundReport: notjunk:1;M01:P0:OSXaVCYcGTU=;6rO4UM2Hl5p2K1jm1sQbU6vxAxa
 MCBmnXS03gfU3vzhyNLYzkJiKMorCKlovpdIPxN4pQiVNAfFP7KZKqT3zG5Sw5XSAv0YB3k7S
 BTCkMGFUeHeYkF3cVxaVuvsYagAbP3S7z/z9LyKmT+gFTSMdVZ+PWzXaGbQdmvrDOMW9uacNd
 euA5swPHkjpx3ObD3vvSbH/07gnvjwPWSEYxXZJkbYa/ZozjrjSeGt2Ahsh4pT8EDDA8w7upi
 5ze4+fL3mLH6zBUdkjbyXYkgQDQlCWCh7mtK/6FBlJ0TwkKdhT1PbUMyMFZ2bjR9FlDU0NtG7
 MnynNeYhp/zc9aYNISggaT4xdnY83X3IsqtShMGja+mo5R2WNilvWkJ27L4tQvUqBiANnfoJl
 ho2j8hqu5jOUE/MC9iLJEvObRyGh/8pommKPjfJs7b0ZDHIhc34iDb5RPs8hmZcqpZfYazmX/
 JCMZG/l67QWNCaXOaIA7fv6uikEit+8i+JCvjffrUmnAxtvz3V83fTawSvg012AaWq/AhuC9S
 LJG2RjXAiDUd7QpScIsS2gGgaxUx1Gr/tHuS3qLC8AMJ3UZvpY68YxwWpRyw8h79yom+Fp27u
 TTW4xv7r6xR80yfy6hIVG1CyOdsh+U/CLXxZDhACBPKJonH67xe7dQTtvWrz+3QHygWIBbtYL
 ANMhvJWAygnxgqzM5mh7Mu8icTtDNM0iHf+vO8RvFtb3oxN5FI4vXXoZr+wAFsl9VPtazh7HC
 uipaCP6Ohb4NlLHw39JN2HEov5z8HE4Y1mBUVAPXNxRERmraLCei9EPMyjC3clLv+GO0BWhaK
 Rzr8tXnxkU8377R/U1W7Av4l5iDc5EQ7DhmZzJK7uWJumfGNYjLP4kYiX+LrxkqR1x3y8iRQa
 BVcT68PoDU4ok9lX2oM6jm+szMPUeVa3/zpETNlgJohqmPrWh8VI6wEVythp/RL63dFrBAs+4
 8AjSAovxzHdteAHVssSeN9cUViA=
X-Spam-Score: -0.7 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Alex Bochannek <alex@HIDDEN> writes:

> diff --git a/doc/emacs/kmacro.texi b/doc/emacs/kmacro.texi

Two small notes from me in addition to Eli's review:

> +(defun kmacro-reg-add-counter-equal (&optional arg)
> +  "Increment `kmacro-counter' by ARG if the counter is equal to a
> +register's value.
> +ARG is the numeric prefix argument that defaults to one."
> +  (interactive "p")
> +  (let
> +      ((register (register-read-with-preview "Compare counter to register: ")))
> +    (kmacro-reg-add-counter '= register arg)))
                               ^^
I think we should function quote here; similar in most of the other
functions.

> +(defun kmacro-quit-counter-equal (&optional arg)
> +  "Quit the keyboard macro if `kmacro-counter' is equal to ARG.
> +ARG is the numeric prefix argument that defaults to zero."
> +  (interactive "P")
> +  (kmacro-quit-counter '= arg))

Is there a reason why the code starts to use the raw prefix here
(capital "P")?


TIA,

Michael.




Message received at control <at> debbugs.gnu.org:


Received: (at control) by debbugs.gnu.org; 4 Sep 2023 08:59:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Sep 04 04:59:27 2023
Received: from localhost ([127.0.0.1]:48581 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qd5Qd-0003Il-3y
	for submit <at> debbugs.gnu.org; Mon, 04 Sep 2023 04:59:27 -0400
Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]:61447)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stefankangas@HIDDEN>) id 1qd5Qa-0003IX-Nu
 for control <at> debbugs.gnu.org; Mon, 04 Sep 2023 04:59:25 -0400
Received: by mail-lf1-x135.google.com with SMTP id
 2adb3069b0e04-4ff09632194so2036813e87.2
 for <control <at> debbugs.gnu.org>; Mon, 04 Sep 2023 01:59:24 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20221208; t=1693817959; x=1694422759; darn=debbugs.gnu.org;
 h=to:subject:message-id:date:mime-version:from:from:to:cc:subject
 :date:message-id:reply-to;
 bh=5zzuyHXOEM7eKGpe7/G9Z/7U8D48578xxfIhJtwvUvI=;
 b=TG/9cdb1N5LliIEIOaZbdqRvQptdaW4a5eEl6AE0+wNG/h+BcRwu34swrwAnasFfUa
 tsvQdyowJs6cxnY6vTS1b+R9xnRawXRRMkxJ4rU0T9wSqmv72TBEy0cFUOe/7/jh236x
 Sd/HWjLccXbvTQNh1Tnv19oyQjx22uqLOmMS4lY/Kuh+IWgTX8NjUA3nhEXKiFU9knLV
 KQ1GjGSFm+eN7k7cN1CcGBhNo1nEf6NsCUC/wjxlGctRcxEhp9Woeo/QCRTxf9m1uIVC
 vizrB3ETJkENOtZV8SmFa5rPTxw4oP7nZy5TY+AlpM7HbSREd4g2M16Sb4jUM3JJyu9h
 QPpQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20221208; t=1693817959; x=1694422759;
 h=to:subject:message-id:date:mime-version:from:x-gm-message-state
 :from:to:cc:subject:date:message-id:reply-to;
 bh=5zzuyHXOEM7eKGpe7/G9Z/7U8D48578xxfIhJtwvUvI=;
 b=CYtMX6NqDI89xWxqhGYcO6yflRohrY8JG1gNv7wE6DN4K7ehXkiwTdv36I/CC0aRin
 EZ2Byw2C0MruVPREDgGDBqPqznuY+lC7ed9adNUjXogRq8og8XgEV77FJyQcfinAFfTU
 U70NYf/mUVDbfQmAvswd+/KHF0zJ1zPZ00j+OOAnw7T0L4xrPtpI0cOE+hUhFZEsG5Q7
 GpPNNOfj/hwsMWnQ9MYaLc9UrL8wcW5YQESDB4hV06WdXB0/+44mIryJI+hReIe1R6vT
 2EnATzm6D2saKfOBTKvjEnLz75GtRb7UA7NM3wmzDQxGNragCae6Rhmeea3q1Sg0h8W7
 461g==
X-Gm-Message-State: AOJu0Yw+B7XL0Q6lss+CdQs5gBYjcz+RuLlTXtdlkPhfk+5t5aWDMgW6
 MYVxyrlYvjXNbMbIdb3Ycl0oObFhF56Gs753ZSlLqeQLzNY=
X-Google-Smtp-Source: AGHT+IHLbL0X7nR9HksKQCNR/njzEkiIeaMUE8Ze+ttF9l7uniCkiKBzv9/BfJlWz9v6u7luq+QMKbW787yfn+wSh70=
X-Received: by 2002:a05:6512:234d:b0:4fd:fd97:a77b with SMTP id
 p13-20020a056512234d00b004fdfd97a77bmr7080718lfu.50.1693817959055; Mon, 04
 Sep 2023 01:59:19 -0700 (PDT)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Mon, 4 Sep 2023 01:59:18 -0700
From: Stefan Kangas <stefankangas@HIDDEN>
MIME-Version: 1.0
Date: Mon, 4 Sep 2023 01:59:18 -0700
Message-ID: <CADwFkmkku6JWJPY9UpU3qG8d3G-z=5xDVBEoHUWfzSvZnAD10g@HIDDEN>
Subject: control message for bug #61549
To: control <at> debbugs.gnu.org
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: control
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

severity 61549 wishlist
quit




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions
Resent-From: Alex Bochannek <alex@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 23 May 2024 00:00:02 +0000
Resent-Message-ID: <handler.61549.B61549.171642236013488 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 61549
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Eli Zaretskii <eliz@HIDDEN>
Cc: larsi@HIDDEN, monnier@HIDDEN, 61549 <at> debbugs.gnu.org
Received: via spool by 61549-submit <at> debbugs.gnu.org id=B61549.171642236013488
          (code B ref 61549); Thu, 23 May 2024 00:00:02 +0000
Received: (at 61549) by debbugs.gnu.org; 22 May 2024 23:59:20 +0000
Received: from localhost ([127.0.0.1]:58236 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1s9vrc-0003VU-Gm
	for submit <at> debbugs.gnu.org; Wed, 22 May 2024 19:59:20 -0400
Received: from ns.lapseofthought.com ([50.0.39.240]:65131
 helo=mail.lapseofthought.com)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <alex@HIDDEN>) id 1s9vrZ-0003VO-ES
 for 61549 <at> debbugs.gnu.org; Wed, 22 May 2024 19:59:18 -0400
Received: from awb-mbp.local (c-24-23-131-202.hsd1.ca.comcast.net
 [24.23.131.202])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by mail.lapseofthought.com (Postfix) with ESMTPSA id 4Vl7Xc2WqZz3pdDR;
 Wed, 22 May 2024 16:57:52 -0700 (PDT)
Authentication-Results: ORIGINATING;
 auth=pass smtp.auth=alex smtp.mailfrom=alex@HIDDEN
From: Alex Bochannek <alex@HIDDEN>
In-Reply-To: <m2a60qwnwu.fsf@HIDDEN> (Alex Bochannek's message of "Sun, 
 05 Mar 2023 19:37:21 -0800")
References: <m2a61ef2i2.fsf@HIDDEN> <83sff41zgm.fsf@HIDDEN>
 <m2lekuo1os.fsf@HIDDEN> <83fsb2xhzp.fsf@HIDDEN>
 <m2a60qwnwu.fsf@HIDDEN>
Date: Wed, 22 May 2024 16:57:51 -0700
Message-ID: <m2jzjl1jsw.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

I am picking up this patch again after not touching it for over a year.
I believe the last feedback was that the docstrings could use some
improvements.

Other than making sure the changes are still relevant and work, any
other recommendations for how to resubmit something that hasn't been
worked on for a while?

-- 
Alex.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Thu, 23 May 2024 05:38:02 +0000
Resent-Message-ID: <handler.61549.B61549.171644262626151 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 61549
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Alex Bochannek <alex@HIDDEN>
Cc: Michael Heerdegen <michael_heerdegen@HIDDEN>, larsi@HIDDEN, monnier@HIDDEN, 61549 <at> debbugs.gnu.org
Received: via spool by 61549-submit <at> debbugs.gnu.org id=B61549.171644262626151
          (code B ref 61549); Thu, 23 May 2024 05:38:02 +0000
Received: (at 61549) by debbugs.gnu.org; 23 May 2024 05:37:06 +0000
Received: from localhost ([127.0.0.1]:58446 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1sA18U-0006nj-2W
	for submit <at> debbugs.gnu.org; Thu, 23 May 2024 01:37:06 -0400
Received: from eggs.gnu.org ([209.51.188.92]:41952)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1sA18R-0006mu-PY
 for 61549 <at> debbugs.gnu.org; Thu, 23 May 2024 01:37:04 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1sA18D-0005CI-PK; Thu, 23 May 2024 01:36:49 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=0/19loCAZiawVteHIt/wrj2qngDDKGMJUL/zddxxmjo=; b=PnIdaoMrIHqY
 7KkI1SzXbM83+Jdjayj2FOiRWq0y+uI1oluhWkn6L1ZKpnHI/uSp7cBB0Q+KNzyHIA9JkG9vi8QIz
 ZNV9rZRwIOAb2/clJYM9gsW+EzMLOd/8oxPHy+xNcn9LWb4FYJ3C01sgbEJHwcqTIeFPR2lSdnmEd
 a0NrE2KWKd/iwfQhZIVtgJMCWqkyv90JtLcQLb4eZekrb0AH6a4TGD/S/IQja3K81ZEMfCp+BsX7U
 QO/M5bJtqFn9wSQSqGFgbHtyikJsmDO3XYCh0aK1kJDXLJ1PHOsyyUah6mZYONCkRzW1K9CwQzs3C
 sXMGCfzlmdBbufbAccKM3A==;
Date: Thu, 23 May 2024 08:36:47 +0300
Message-Id: <86ed9t5btc.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <m2jzjl1jsw.fsf@HIDDEN> (message from Alex Bochannek on
 Wed, 22 May 2024 16:57:51 -0700)
References: <m2a61ef2i2.fsf@HIDDEN> <83sff41zgm.fsf@HIDDEN>
 <m2lekuo1os.fsf@HIDDEN> <83fsb2xhzp.fsf@HIDDEN>
 <m2a60qwnwu.fsf@HIDDEN> <m2jzjl1jsw.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Alex Bochannek <alex@HIDDEN>
> Cc: monnier@HIDDEN,  larsi@HIDDEN,  61549 <at> debbugs.gnu.org
> Date: Wed, 22 May 2024 16:57:51 -0700
> 
> I am picking up this patch again after not touching it for over a year.
> I believe the last feedback was that the docstrings could use some
> improvements.

No, not AFAICT.  There were review comments in

        https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61549#20
and in
        https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61549#23

and they were not only about documentation.

> Other than making sure the changes are still relevant and work, any
> other recommendations for how to resubmit something that hasn't been
> worked on for a while?

Rebase on the current master, that's all.

Thanks.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions
Resent-From: Alex Bochannek <alex@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sat, 01 Jun 2024 00:21:02 +0000
Resent-Message-ID: <handler.61549.B61549.171720125322050 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 61549
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Eli Zaretskii <eliz@HIDDEN>
Cc: Michael Heerdegen <michael_heerdegen@HIDDEN>, larsi@HIDDEN, monnier@HIDDEN, 61549 <at> debbugs.gnu.org
Received: via spool by 61549-submit <at> debbugs.gnu.org id=B61549.171720125322050
          (code B ref 61549); Sat, 01 Jun 2024 00:21:02 +0000
Received: (at 61549) by debbugs.gnu.org; 1 Jun 2024 00:20:53 +0000
Received: from localhost ([127.0.0.1]:55485 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1sDCUO-0005jY-Kn
	for submit <at> debbugs.gnu.org; Fri, 31 May 2024 20:20:53 -0400
Received: from ns.lapseofthought.com ([50.0.39.240]:19022
 helo=mail.lapseofthought.com)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <alex@HIDDEN>) id 1sDCUI-0005jM-MH
 for 61549 <at> debbugs.gnu.org; Fri, 31 May 2024 20:20:50 -0400
Received: from awb-mbp.local (c-24-23-131-202.hsd1.ca.comcast.net
 [24.23.131.202])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by mail.lapseofthought.com (Postfix) with ESMTPSA id 4VrgZw1z0bz3qMSW;
 Fri, 31 May 2024 17:19:04 -0700 (PDT)
Authentication-Results: ORIGINATING;
 auth=pass smtp.auth=alex smtp.mailfrom=alex@HIDDEN
From: Alex Bochannek <alex@HIDDEN>
In-Reply-To: <86ed9t5btc.fsf@HIDDEN> (Eli Zaretskii's message of "Thu, 23 May
 2024 08:36:47 +0300")
References: <m2a61ef2i2.fsf@HIDDEN> <83sff41zgm.fsf@HIDDEN>
 <m2lekuo1os.fsf@HIDDEN> <83fsb2xhzp.fsf@HIDDEN>
 <m2a60qwnwu.fsf@HIDDEN> <m2jzjl1jsw.fsf@HIDDEN>
 <86ed9t5btc.fsf@HIDDEN>
Date: Fri, 31 May 2024 17:19:02 -0700
Message-ID: <m2cyp1tszt.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-Spam-Score: -0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

--=-=-=
Content-Type: text/plain

Eli,

Thanks for the reminder of the other review comments. I went through
those and addressed them.

I am attaching the changes to:
  NEWS
  kmacro.el
  kmacro-tests.el

I hope this is the last iteration, but please let me know if there are
stylistic or implementation issues.

Thanks!

Eli Zaretskii <eliz@HIDDEN> writes:

>> From: Alex Bochannek <alex@HIDDEN>
>> Cc: monnier@HIDDEN,  larsi@HIDDEN,  61549 <at> debbugs.gnu.org
>> Date: Wed, 22 May 2024 16:57:51 -0700
>> 
>> I am picking up this patch again after not touching it for over a year.
>> I believe the last feedback was that the docstrings could use some
>> improvements.
>
> No, not AFAICT.  There were review comments in
>
>         https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61549#20
> and in
>         https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61549#23
>
> and they were not only about documentation.

	Advanced keyboard macro counter commands for register
	integration and conditional macro termination

	* etc/NEWS:
	Document advanced keyboard macro counter commands.

	* lisp/kmacro.el (kmacro-keymap)
	(kmacro-reg-load-counter, kmacro-reg-save-counter)
	(kmacro-reg-add-counter-equal, kmacro-reg-add-counter-less)
	(kmacro-reg-add-counter-greater, kmacro-reg-add-counter)
	(kmacro-quit-counter-equal, kmacro-quit-counter-less)
	(kmacro-quit-counter-greater, kmacro-quit-counter):
	Add advanced keyboard macro counter commands to kmacro keymap.
	Implement advanced keyboard macro counter commands.

	* test/lisp/kmacro-tests.el (kmacro-tests-test-reg-load)
	(kmacro-tests-test-reg-save)
	(kmacro-tests-test-reg-add-counter-equal-01)
	(kmacro-tests-test-reg-add-counter-equal-02)
	(kmacro-tests-test-reg-add-counter-equal-03)
	(kmacro-tests-test-reg-add-counter-equal-04)
	(kmacro-tests-test-reg-add-counter-less)
	(kmacro-tests-test-reg-add-counter-greater)
	(kmacro-tests-test-quit-counter-equal-01)
	(kmacro-tests-test-quit-counter-equal-02)
	(kmacro-tests-test-quit-counter-equal-03)
	(kmacro-tests-test-quit-counter-equal-04)
	(kmacro-tests-test-quit-counter-less)
	(kmacro-tests-test-quit-counter-greater):
	Implement unit tests for advanced keyboard macro counter
	commands.

--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/etc/NEWS b/etc/NEWS
index 3c672ffed8f..0675afe9505 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1682,6 +1682,25 @@ The user option 'proced-auto-update-flag' can now be set to 2 additional
 values, which control automatic updates of Proced buffers that are not
 displayed in some window.
 
+** Kmacro
+
++++
+*** New Advanced Macro Counter functions.
+New commands have been added to implement advanced macro counter
+functions.
+
+The commands 'C-x C-k C-r l' and 'C-x C-k C-r s' load and save the
+macro counter from and to a number register, respectively.
+
+The commands 'C-x C-k C-r a =', 'C-x C-k C-r a <', and
+'C-x C-k C-r a >' compare the macro counter with the contents of a
+number register and increment the counter by an optional prefix if the
+comparison succeeds.
+
+The commands 'C-x C-k C-q =', 'C-x C-k C-q <', and 'C-x C-k C-q >'
+compare the macro counter with an optional prefix and terminate the
+macro if the comparison succeeds.
+
 ** Kmacro Menu mode
 
 +++

--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/lisp/kmacro.el b/lisp/kmacro.el
index 07a13d5632c..277de517443 100644
--- a/lisp/kmacro.el
+++ b/lisp/kmacro.el
@@ -187,6 +187,14 @@ kmacro-keymap
   "C-c"     #'kmacro-set-counter
   "C-i"     #'kmacro-insert-counter
   "C-a"     #'kmacro-add-counter
+  "C-r l"   #'kmacro-reg-load-counter
+  "C-r s"   #'kmacro-reg-save-counter
+  "C-r a =" #'kmacro-reg-add-counter-equal
+  "C-r a <" #'kmacro-reg-add-counter-less
+  "C-r a >" #'kmacro-reg-add-counter-greater
+  "C-q ="   #'kmacro-quit-counter-equal
+  "C-q <"   #'kmacro-quit-counter-less
+  "C-q >"   #'kmacro-quit-counter-greater
 
   ;; macro editing
   "C-e"  #'kmacro-edit-macro-repeat
@@ -346,6 +354,82 @@ kmacro-add-counter
   (unless executing-kbd-macro
     (kmacro-display-counter)))
 
+(defun kmacro-reg-load-counter (register)
+  "Load the value of a REGISTER into `kmacro-counter'."
+  (interactive
+   (list (register-read-with-preview "Load register to counter: ")))
+  (let ((register-val (get-register register)))
+    (when (numberp register-val)
+      (setq kmacro-counter register-val))))
+
+(defun kmacro-reg-save-counter (register)
+  "Save the value of `kmacro-counter' to a REGISTER."
+  (interactive
+   (list (register-read-with-preview "Save counter to register: ")))
+  (set-register register kmacro-counter))
+
+(defun kmacro-reg-add-counter-equal (&optional arg)
+  "Increment counter by one if it is equal to register value.
+Optional non-nil ARG specifies the increment."
+  (interactive "p")
+  (let
+      ((register (register-read-with-preview "Compare counter to register: ")))
+    (kmacro-reg-add-counter #'= register arg)))
+
+(defun kmacro-reg-add-counter-less (&optional arg)
+  "Increment counter by one if it is less than register value.
+Optional non-nil ARG specifies increment."
+  (interactive "p")
+  (let
+      ((register (register-read-with-preview "Compare counter to register: ")))
+    (kmacro-reg-add-counter #'< register arg)))
+
+
+(defun kmacro-reg-add-counter-greater (&optional arg)
+  "Increment counter by one if it is greater than register value.
+Optional non-nil ARG specifies increment."
+  (interactive "p")
+  (let
+      ((register (register-read-with-preview "Compare counter to register: ")))
+    (kmacro-reg-add-counter #'> register arg)))
+
+(defun kmacro-reg-add-counter (pred register arg)
+  "Increment `kmacro-counter' by ARG if PRED returns non-nil.
+PRED is called with two arguments: `kmacro-counter' and REGISTER."
+  (let ((register-val (get-register register)))
+    (when (funcall pred kmacro-counter register-val)
+      (setq current-prefix-arg nil)
+      (kmacro-add-counter arg))))
+
+(defun kmacro-quit-counter-equal (&optional arg)
+  "Quit the keyboard macro if the counter is equal to zero.
+Optional non-nil ARG specifies comparison value."
+  (interactive "p")
+  (kmacro-quit-counter #'= arg))
+
+(defun kmacro-quit-counter-less (&optional arg)
+  "Quit the keyboard macro if the counter is less than zero.
+Optional non-nil ARG specifies comparison value."
+  (interactive "p")
+  (kmacro-quit-counter #'< arg))
+
+(defun kmacro-quit-counter-greater (&optional arg)
+  "Quit the keyboard macro if the counter is greater than zero.
+Optional non-nil ARG specifies comparison value."
+  (interactive "p")
+  (kmacro-quit-counter #'> arg))
+
+(defun kmacro-quit-counter (pred arg)
+  "Quit the keyboard macro if PRED returns non-nil.
+PRED is called with two arguments: `kmacro-counter' and ARG.
+ARG specifies comparison value or zero if nil."
+  (when kmacro-initial-counter-value
+    (setq kmacro-counter kmacro-initial-counter-value
+          kmacro-initial-counter-value nil))
+  (let ((arg (if (null current-prefix-arg)
+                 0 arg)))
+    (when (funcall pred kmacro-counter arg)
+      (keyboard-quit))))
 
 (defun kmacro-loop-setup-function ()
   "Function called prior to each iteration of macro."

--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/test/lisp/kmacro-tests.el b/test/lisp/kmacro-tests.el
index 2eead234988..52abe138ae9 100644
--- a/test/lisp/kmacro-tests.el
+++ b/test/lisp/kmacro-tests.el
@@ -275,6 +275,219 @@ kmacro-tests-start-insert-counter-appends-to-macro
     ;;  Verify that the recording state has changed.
     (should (equal defining-kbd-macro 'append))))
 
+
+(kmacro-tests-deftest kmacro-tests-test-reg-load ()
+  "`kmacro-reg-load-counter' loads the value of a register into the counter."
+  (set-register ?\C-r 4) ;; Should be safe as a register name
+  (kmacro-tests-simulate-command '(kmacro-set-counter 1))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              "\C-x\C-k\C-i"
+                              ;; Load from register
+                              "\C-x\C-k\C-rl\C-r"
+                              ))
+  (kmacro-tests-should-insert "1245"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 2)))
+    (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-save ()
+  "`kmacro-reg-save-counter' saves the counter to a register."
+  (set-register ?\C-r nil) ;; Should be safe as a register name
+  (kmacro-tests-simulate-command '(kmacro-set-counter 1))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Save to register
+                              "\C-x\C-k\C-rs\C-r"
+                              ;; Add to counter
+                              "\C-u2\C-x\C-k\C-a"
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Insert register
+                              "\C-xri\C-r"
+                              ))
+  (kmacro-tests-should-insert "142586"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 2)))
+  (set-register ?\C-r nil))
+
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-equal-01 ()
+  "`kmacro-reg-add-counter-equal' increments counter by one if equal to register."
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Increment counter if it matches
+                              "\C-x\C-k\C-ra=\C-r"
+                              ))
+  (kmacro-tests-should-insert "0134"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-equal-02 ()
+  "`kmacro-reg-add-counter-equal' increments counter by prefix if equal to register."
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Add two to counter if it matches
+                              "\C-u2\C-x\C-k\C-ra=\C-r"
+                              ))
+  (kmacro-tests-should-insert "0145"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-equal-03 ()
+  "`kmacro-reg-add-counter-equal' increments counter by universal arg if equal to register."
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Add four to counter if it matches
+                              "\C-u\C-x\C-k\C-ra=\C-r"
+                              ))
+  (kmacro-tests-should-insert "0167"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-equal-04 ()
+  "`kmacro-reg-add-counter-equal' decrements counter by one if equal to register."
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Decrement counter if it matches
+                              "\C-u-\C-x\C-k\C-ra=\C-r"
+                              ))
+  (kmacro-tests-should-insert "0111"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-less ()
+  "`kmacro-reg-add-counter-less' decrements counter if less than register."
+  (set-register ?\C-r 6) ;; Should be safe as a register name
+  (kmacro-tests-simulate-command '(kmacro-set-counter 7))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Decrement counter if it's
+                              ;; less than the register
+                              "\C-u-\C-x\C-k\C-ra<\C-r"
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ))
+  (kmacro-tests-should-insert "7642"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+    (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-greater ()
+  "`kmacro-reg-add-counter-greater' increments counter if greater than register."
+  (set-register ?\C-r 1) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Increment counter if it's greater
+                              ;; than the register
+                              "\C-x\C-k\C-ra>\C-r"
+                              ))
+  (kmacro-tests-should-insert "0135"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-equal-01 ()
+  "`kmacro-quit-counter-equal' stops macro if counter is equal to positive prefix."
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Stop if the counter is at 5
+                              "\C-u5\C-x\C-k\C-q="
+                              ))
+  (kmacro-tests-should-insert "0123"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (= 4 kmacro-counter))
+  (should (condition-case abort
+            (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-equal-02 ()
+  "`kmacro-quit-counter-equal' stops macro if counter is equal to zero."
+  (kmacro-tests-simulate-command '(kmacro-set-counter 5))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ;; Stop if the counter is at 0
+                              "\C-x\C-k\C-q="
+                              ))
+  (kmacro-tests-should-insert "5432"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (= 1 kmacro-counter))
+  (should (condition-case abort
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-equal-03 ()
+  "`kmacro-quit-counter-equal' stops macro if counter is equal to negative prefix."
+  (kmacro-tests-simulate-command '(kmacro-set-counter 4))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ;; Stop if the counter is at -1
+                              "\C-u-\C-x\C-k\C-q="
+                              ))
+  (kmacro-tests-should-insert "4321"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (= 0 kmacro-counter))
+  (should (condition-case abort
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-equal-04 ()
+  "`kmacro-quit-counter-equal' doesn't stop macro if counter doesn't equal prefix."
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-u2\C-x\C-k\C-i"
+                              ;; Stop if the counter is at 7
+                              "\C-u7\C-x\C-k\C-q="
+                              ))
+  (kmacro-tests-should-insert "0246"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should-not (condition-case abort
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+              (quit abort)))
+  (should (= 10 kmacro-counter)))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-less ()
+  "`kmacro-quit-counter-less' stops macro if counter is less than prefix."
+  (kmacro-tests-simulate-command '(kmacro-set-counter 8))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Stop if the counter is less than 5
+                              "\C-u5\C-x\C-k\C-q<"
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ))
+  (kmacro-tests-should-insert "8765"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 4 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-greater ()
+  "`kmacro-quit-counter-greater' stops macro if counter is greater than prefix."
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Stop if the counter is greater than 4
+                              "\C-u4\C-x\C-k\C-q>"
+                              ))
+  (kmacro-tests-should-insert "0123"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 4 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+
 (kmacro-tests-deftest kmacro-tests-end-call-macro-prefix-args ()
   "kmacro-end-call-macro changes behavior based on prefix arg."
   ;; "Record" two macros.

--=-=-=
Content-Type: text/plain

-- 
Alex.

--=-=-=--




Message sent:


MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Eli Zaretskii <eliz@HIDDEN>
Subject: bug#61549: closed (30.0.50; [PATCH] New keyboard macro counter
 functions)
CC: tracker <at> debbugs.gnu.org
Message-ID: <handler.61549.D61549.171730814224067.ackdone <at> debbugs.gnu.org>
References: <861q5fopbf.fsf@HIDDEN> <m2a61ef2i2.fsf@HIDDEN>
X-Gnu-PR-Message: closed 61549
X-Gnu-PR-Package: emacs
X-Gnu-PR-Keywords: patch
Date: Sun, 02 Jun 2024 06:03:02 +0000
Content-Type: multipart/mixed; boundary="----------=_1717308182-24150-0"

This is a multi-part message in MIME format...

------------=_1717308182-24150-0
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=utf-8

Your message dated Sun, 02 Jun 2024 09:01:56 +0300
with message-id <861q5fopbf.fsf@HIDDEN>
and subject line Re: bug#61549: 30.0.50; [PATCH] New keyboard macro counter=
 functions
has caused the debbugs.gnu.org bug report #61549,
regarding 30.0.50; [PATCH] New keyboard macro counter functions
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs@HIDDEN)


--=20
61549: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D61549
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems

------------=_1717308182-24150-0
Content-Type: message/rfc822
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Received: (at submit) by debbugs.gnu.org; 16 Feb 2023 08:18:44 +0000
Received: from localhost ([127.0.0.1]:34785 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSZTW-0001Dt-Pv
	for submit <at> debbugs.gnu.org; Thu, 16 Feb 2023 03:18:44 -0500
Received: from lists.gnu.org ([209.51.188.17]:46082)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <alex@HIDDEN>) id 1pSZTR-0001Dh-C8
 for submit <at> debbugs.gnu.org; Thu, 16 Feb 2023 03:18:41 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <alex@HIDDEN>)
 id 1pSZTQ-0004nY-Qt
 for bug-gnu-emacs@HIDDEN; Thu, 16 Feb 2023 03:18:36 -0500
Received: from ns.lapseofthought.com ([50.0.39.240]
 helo=mail.lapseofthought.com)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <alex@HIDDEN>)
 id 1pSZTM-0005b6-Q9
 for bug-gnu-emacs@HIDDEN; Thu, 16 Feb 2023 03:18:36 -0500
Received: from awb-mbp.local (c-73-92-249-246.hsd1.ca.comcast.net
 [73.92.249.246])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by mail.lapseofthought.com (Postfix) with ESMTPSA id 4PHSVG0nlwz3pf5q
 for <bug-gnu-emacs@HIDDEN>; Thu, 16 Feb 2023 00:17:26 -0800 (PST)
Authentication-Results: ORIGINATING;
 auth=pass smtp.auth=alex smtp.mailfrom=alex@HIDDEN
From: Alex Bochannek <alex@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 30.0.50; [PATCH] New keyboard macro counter functions
Date: Thu, 16 Feb 2023 00:17:25 -0800
Message-ID: <m2a61ef2i2.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=50.0.39.240; envelope-from=alex@HIDDEN;
 helo=mail.lapseofthought.com
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

--=-=-=
Content-Type: text/plain

Hello!

I have been working on blog posts about keyboard macros and found that
it would be useful to have comparison functions for the keyboard macro
counter.

I implemented two functions to load and save macro counter values from
and to number registers; three comparison functions of the macro counter
with a number register that conditionally increment the counter; three
comparison functions of the macro counter with a prefix that terminate
the macro execution. This simplifies handling multiple counters and
conditional macro termination.

I am attaching the changes to:
  emacs.texi
  kmacro.texi
  NEWS
  kmacro.el
  kmacro-tests.el

I hope this functionality is useful and that I followed the coding and
style standards.

Thanks!

	Advanced keyboard macro counter commands for register
	integration and conditional macro termination

	* doc/emacs/emacs.texi (Top):
	Document advanced keyboard macro counter commands.

	* doc/emacs/kmacro.texi (Keyboard Macros, Keyboard Macro Counter):
	Document advanced keyboard macro counter commands.

	* etc/NEWS:
	Document advanced keyboard macro counter commands.

	* lisp/kmacro.el (kmacro-keymap, kmacro-reg-load-counter)
	(kmacro-reg-save-counter, kmacro-reg-add-counter-equal)
	(kmacro-reg-add-counter-equal, kmacro-reg-add-counter-less)
	(kmacro-reg-add-counter-greater, kmacro-reg-add-counter)
	(kmacro-quit-counter-equal, kmacro-quit-counter-less)
	(kmacro-quit-counter-greater, kmacro-quit-counter):
	Add advanced keyboard macro counter commands to kmacro keymap.
	Implement advanced keyboard macro counter commands.

	* test/lisp/kmacro-tests.el (kmacro-tests-test-reg-load)
	(kmacro-tests-test-reg-save)
	(kmacro-tests-test-reg-add-counter-equal-01)
	(kmacro-tests-test-reg-add-counter-equal-02)
	(kmacro-tests-test-reg-add-counter-equal-03)
	(kmacro-tests-test-reg-add-counter-equal-04)
	(kmacro-tests-test-reg-add-counter-less)
	(kmacro-tests-test-reg-add-counter-greater)
	(kmacro-tests-test-quit-counter-equal-01)
	(kmacro-tests-test-quit-counter-equal-02)
	(kmacro-tests-test-quit-counter-equal-03)
	(kmacro-tests-test-quit-counter-equal-04)
	(kmacro-tests-test-quit-counter-less)
	(kmacro-tests-test-quit-counter-greater):
	Implement unit tests for advanced keyboard macro counter
	commands.

--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi
index 7071ea44edd..2584dce8d44 100644
--- a/doc/emacs/emacs.texi
+++ b/doc/emacs/emacs.texi
@@ -434,6 +434,7 @@ Top
 * Basic Keyboard Macro::     Defining and running keyboard macros.
 * Keyboard Macro Ring::      Where previous keyboard macros are saved.
 * Keyboard Macro Counter::   Inserting incrementing numbers in macros.
+* Advanced Macro Counter::   Advanced macro counter commands.
 * Keyboard Macro Query::     Making keyboard macros do different things each
                                 time.
 * Save Keyboard Macro::      Giving keyboard macros names; saving them in

--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/doc/emacs/kmacro.texi b/doc/emacs/kmacro.texi
index fc1402b489d..27c84c0f96f 100644
--- a/doc/emacs/kmacro.texi
+++ b/doc/emacs/kmacro.texi
@@ -35,6 +35,7 @@ Keyboard Macros
 * Basic Keyboard Macro::     Defining and running keyboard macros.
 * Keyboard Macro Ring::      Where previous keyboard macros are saved.
 * Keyboard Macro Counter::   Inserting incrementing numbers in macros.
+* Advanced Macro Counter::   Advanced macro counter commands.
 * Keyboard Macro Query::     Making keyboard macros do different things each
                                time.
 * Save Keyboard Macro::      Giving keyboard macros names; saving them in
@@ -364,6 +365,123 @@ Keyboard Macro Counter
 keyboard macro counter.  @xref{Number Registers}.  For most purposes,
 it is simpler to use a keyboard macro counter.
 
+@node Advanced Macro Counter
+@section Advanced Macro Counter Commands
+
+  The counter associated with a keyboard macro is sufficient in most
+cases.  If additional counters are required for a macro, registers can
+be used and these advanced macro counter commands simplify the
+interaction between the two.  Additional commands are provided to
+terminate a macro after a predefined number of runs.
+
+
+@table @kbd
+@item C-x C-k C-r l
+Load the value of a number register into the macro counter
+(@code{kmacro-reg-load-counter}).
+@item C-x C-k C-r s
+Save the value of the macro counter to a number register
+(@code{kmacro-reg-save-counter}).
+@end table
+
+@table @kbd
+@item C-x C-k C-r a =
+Compare if the macro counter is equal to the value of a register and
+increment the counter if it is (@code{kmacro-reg-add-counter-equal}).
+@item C-x C-k C-r a <
+Compare if the macro counter is less than the value of a register and
+increment the counter if it is (@code{kmacro-reg-add-counter-less}).
+@item C-x C-k C-r a >
+Compare if the macro counter is greater than the value of a register
+and increment the counter if it is
+(@code{kmacro-reg-add-counter-greater}).
+@end table
+
+@table @kbd
+@item C-x C-k C-q =
+Compare if the macro counter is equal to the prefix and terminate the
+macro if it is (@code{kmacro-quit-counter-equal}).
+@item C-x C-k C-q <
+Compare if the macro counter is less than the prefix and terminate the
+macro if it is (@code{kmacro-quit-counter-less}).
+@item C-x C-k C-q >
+Compare if the macro counter is greater than the prefix and terminate
+the macro if it is (@code{kmacro-quit-counter-greater}).
+@end table
+
+@findex kmacro-reg-load-counter
+@kindex C-x C-k C-r l
+@findex kmacro-reg-save-counter
+@kindex C-x C-k C-r s
+  The command @kbd{C-x C-k C-r l} (@code{kmacro-reg-load-counter})
+prompts for the register name from which to load a number into the
+macro counter.  The command @kbd{C-x C-k C-r s}
+(@code{kmacro-reg-save-counter}) prompts for the register name into
+which to save the macro counter's value.  Both @kbd{C-x C-k C-r l}
+(@code{kmacro-reg-load-counter}) and @kbd{C-x C-k C-r s}
+(@code{kmacro-reg-save-counter}) show a preview of the registers by
+default.  @xref{Registers}.  Both commands can be used during or
+outside a keyboard macro definition.
+
+@findex kmacro-reg-add-counter-equal
+@kindex C-x C-k C-r a =
+@findex kmacro-reg-add-counter-less
+@kindex C-x C-k C-r a <
+@findex kmacro-reg-add-counter-greater
+@kindex C-x C-k C-r a >
+  The @kbd{C-x C-k C-r a =} (@code{kmacro-reg-add-counter-equal}),
+@kbd{C-x C-k C-r a <} (@code{kmacro-reg-add-counter-less}), and
+@kbd{C-x C-k C-r a >} (@code{kmacro-reg-add-counter-greater}) commands
+all follow the same pattern.  During keyboard macro definition, the
+command prompts for a register name (with preview by default), the
+contents of which will be compared with the macro counter's value.  If
+the counter is equal to (@code{=}), less than (@code{<}), or greater
+than (@code{>}) the number register's contents, the counter will be
+incremented by the numeric prefix or one if no prefix was given to the
+command.
+
+  For example,
+
+@example
+C-u 2 C-x C-k C-r a > N
+@end example
+
+@noindent
+compares the counter with the contents of register @code{N} and if the
+counter is greater than that, increases it by two.
+
+@findex kmacro-quit-counter-equal
+@kindex C-x C-k C-q =
+@findex kmacro-quit-counter-less
+@kindex C-x C-k C-q <
+@findex kmacro-quit-counter-greater
+@kindex C-x C-k C-q >
+  Finally, the @kbd{C-x C-k C-q =} (@code{kmacro-quit-counter-equal}),
+@kbd{C-x C-k C-q <} (@code{kmacro-quit-counter-less}), and @kbd{C-x
+C-k C-q >} (@code{kmacro-quit-counter-greater}) commands compare the
+macro counter with the prefix given and terminate the execution of the
+macro, if the comparison succeeds.  If no numeric prefix or only
+@code{C-u} are given, the counter will be compared with zero.  The
+macro is terminated using the @code{keyboard-quit} function.  Using
+this command to exit from a macro that has been called by another
+macro is not supported, the entire executing macro is terminated.
+
+  The quit commands can be used to construct the equivalent of a
+@code{while}-loop. This example will stop after ten executions
+assuming the starting value for the macro counter is the default zero.
+
+@example
+C-u 10 C-x C-k C-q = C-x C-k C-i @key{RET}
+@end example
+
+  With the default counter value of zero, the macro called with a
+prefix of @code{C-u C-u} to execute sixteen times, will stop after ten
+iterations.  The counter values that have been inserted will be from 0
+to 9.  If the counter starts out a different value below ten, it will
+still stop at ten, because the counter does not actually count macro
+executions, but is incremented explicitly by the @code{C-x C-k C-i}
+command.
+
 @node Keyboard Macro Query
 @section Executing Macros with Variations

--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/etc/NEWS b/etc/NEWS
index 4fbe09e0541..d5a3ebb1df5 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -187,6 +187,25 @@ This command adds a docstring comment to the current defun.  If a
 comment already exists, point is only moved to the comment.  It is
 bound to 'C-c C-d' in 'go-ts-mode'.
 
+** Kmacro
+
++++
+*** New Advanced Macro Counter functions.
+New commands have been added to to implement advanced macro counter
+functions.
+
+The commands 'C-x C-k C-r l' and 'C-x C-k C-r s' load and save the
+macro counter from a to a number register respectively.
+
+The commands 'C-x C-k C-r a =', 'C-x C-k C-r a <', and
+'C-x C-k C-r a >' compare the macro counter with the contents of a
+number register and increment the counter by a prefix if the
+comparison succeeds.
+
+The commands 'C-x C-k C-q =', 'C-x C-k C-q <', and 'C-x C-k C-q >'
+compare the macro counter with a prefix and terminate the macro if the
+comparison succeeds.
+
 
 * New Modes and Packages in Emacs 30.1
 
--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/lisp/kmacro.el b/lisp/kmacro.el
index 94d8794bd23..e7c3f75efd0 100644
--- a/lisp/kmacro.el
+++ b/lisp/kmacro.el
@@ -183,10 +183,18 @@ kmacro-keymap
   "C-l"  #'kmacro-call-ring-2nd-repeat
 
   ;; macro counter
-  "C-f"  #'kmacro-set-format
-  "C-c"  #'kmacro-set-counter
-  "C-i"  #'kmacro-insert-counter
-  "C-a"  #'kmacro-add-counter
+  "C-f"     #'kmacro-set-format
+  "C-c"     #'kmacro-set-counter
+  "C-i"     #'kmacro-insert-counter
+  "C-a"     #'kmacro-add-counter
+  "C-r l"   #'kmacro-reg-load-counter
+  "C-r s"   #'kmacro-reg-save-counter
+  "C-r a =" #'kmacro-reg-add-counter-equal
+  "C-r a <" #'kmacro-reg-add-counter-less
+  "C-r a >" #'kmacro-reg-add-counter-greater
+  "C-q ="   #'kmacro-quit-counter-equal
+  "C-q <"   #'kmacro-quit-counter-less
+  "C-q >"   #'kmacro-quit-counter-greater
 
   ;; macro editing
   "C-e"  #'kmacro-edit-macro-repeat
@@ -347,6 +355,89 @@ kmacro-add-counter
     (kmacro-display-counter)))
 
 
+(defun kmacro-reg-load-counter (register)
+  "Load the value of a register into `kmacro-counter'"
+  (interactive
+   (list (register-read-with-preview "Load register to counter: ")))
+  (let ((register-val (get-register register)))
+    (when (numberp register-val)
+     (setq kmacro-counter register-val))))
+
+
+(defun kmacro-reg-save-counter (register)
+  "Save the value of `kmacro-counter' to a register"
+  (interactive
+   (list (register-read-with-preview "Save counter to register: ")))
+  (set-register register kmacro-counter))
+
+
+(defun kmacro-reg-add-counter-equal (&optional arg)
+  "Increment counter by ARG if it is equal to register value"
+  (interactive "p")
+  (let
+      ((register (register-read-with-preview "Compare counter to register: ")))
+    (kmacro-reg-add-counter '= register arg)))
+
+
+(defun kmacro-reg-add-counter-less (&optional arg)
+  "Increment counter by ARG if it is less than register value"
+  (interactive "p")
+  (let
+      ((register (register-read-with-preview "Compare counter to register: ")))
+    (kmacro-reg-add-counter '< register arg)))
+
+
+(defun kmacro-reg-add-counter-greater (&optional arg)
+  "Increment counter by ARG if it is greater than register value"
+  (interactive "p")
+  (let
+      ((register (register-read-with-preview "Compare counter to register: ")))
+    (kmacro-reg-add-counter '> register arg)))
+
+
+(defun kmacro-reg-add-counter (func register &optional arg)
+  "Increment the counter by ARG if (FUNC kmacro-counter REGISTER-VALUE)
+is true.
+With no ARG, ARG is set to 1"
+  (let ((register-val (get-register register))
+        (arg (if (null arg) 1 arg)))
+    (when (apply func (list kmacro-counter register-val))
+      (setq current-prefix-arg nil)
+      (kmacro-add-counter arg))))
+
+
+(defun kmacro-quit-counter-equal (&optional arg)
+  "Quit the keyboard macro if the counter is equal to ARG"
+  (interactive "P")
+  (kmacro-quit-counter '= arg))
+
+
+(defun kmacro-quit-counter-less (&optional arg)
+  "Quit the keyboard macro if the counter is less than ARG"
+  (interactive "P")
+  (kmacro-quit-counter '< arg))
+
+
+(defun kmacro-quit-counter-greater (&optional arg)
+  "Quit the keyboard macro if the counter is greater than ARG"
+    (interactive "P")
+    (kmacro-quit-counter '> arg))
+
+
+(defun kmacro-quit-counter (func &optional arg)
+  "Quit the keyboard macro if (FUNC kmacro-counter ARG) is true.
+With \\[universal-argument] or no ARG, ARG is set to 0"
+  (when kmacro-initial-counter-value
+      (setq kmacro-counter kmacro-initial-counter-value
+	    kmacro-initial-counter-value nil))
+  (let ((arg
+	 (cond ((or (consp arg) (null arg)) 0)
+	       ((eq '- arg) -1)
+	       (t arg))))
+    (when (apply func (list kmacro-counter arg))
+      (keyboard-quit))))
+
+
 (defun kmacro-loop-setup-function ()
   "Function called prior to each iteration of macro."
   ;; Restore macro counter format to initial format, so it is ok to change

--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/test/lisp/kmacro-tests.el b/test/lisp/kmacro-tests.el
index 551fd8b60fc..e30681db539 100644
--- a/test/lisp/kmacro-tests.el
+++ b/test/lisp/kmacro-tests.el
@@ -275,6 +275,220 @@ kmacro-tests-start-insert-counter-appends-to-macro
     ;;  Verify that the recording state has changed.
     (should (equal defining-kbd-macro 'append))))
 
+
+(kmacro-tests-deftest kmacro-tests-test-reg-load ()
+  "`kmacro-reg-load-counter' loads the value of register to into the counter"
+  (set-register ?\C-r 4) ;; Should be safe as a register name
+  (kmacro-tests-simulate-command '(kmacro-set-counter 1))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              "\C-x\C-k\C-i"
+                              ;; Load from register
+                              "\C-x\C-k\C-rl\C-r"
+                              ))
+  (kmacro-tests-should-insert "1245"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 2)))
+    (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-save ()
+  "`kmacro-reg-save-counter' save the counter to a register"
+  (set-register ?\C-r nil) ;; Should be safe as a register name
+  (kmacro-tests-simulate-command '(kmacro-set-counter 1))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Save to register
+                              "\C-x\C-k\C-rs\C-r"
+                              ;; Add to counter
+                              "\C-u2\C-x\C-k\C-a"
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Insert register
+                              "\C-xri\C-r"
+                              ))
+  (kmacro-tests-should-insert "142586"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 2)))
+  (set-register ?\C-r nil))
+
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-equal-01 ()
+  "`kmacro-reg-add-counter-equal' increments counter if equal to register"
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Increment counter if it matches
+                              "\C-x\C-k\C-ra=\C-r"
+                              ))
+  (kmacro-tests-should-insert "0134"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-equal-02 ()
+  "`kmacro-reg-add-counter-equal' increments counter if equal to register"
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Add two to counter if it matches
+                              "\C-u2\C-x\C-k\C-ra=\C-r"
+                              ))
+  (kmacro-tests-should-insert "0145"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-equal-03 ()
+  "`kmacro-reg-add-counter-equal' increments counter if equal to register"
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Add four to counter if it matches
+                              "\C-u\C-x\C-k\C-ra=\C-r"
+                              ))
+  (kmacro-tests-should-insert "0167"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-equal-04 ()
+  "`kmacro-reg-add-counter-equal' increments counter if equal to register"
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Decrement counter if it matches
+                              "\C-u-\C-x\C-k\C-ra=\C-r"
+                              ))
+  (kmacro-tests-should-insert "0111"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-less ()
+  "`kmacro-reg-add-counter-less' increments counter if less than register"
+  (set-register ?\C-r 6) ;; Should be safe as a register name
+  (kmacro-tests-simulate-command '(kmacro-set-counter 8))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Decrement counter if it's
+                              ;; less than the register
+                              "\C-u-1\C-x\C-k\C-ra<\C-r"
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ))
+  (kmacro-tests-should-insert "8764"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+    (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-greater ()
+  "`kmacro-reg-add-counter-greater' increments counter if greater than register"
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Increment counter if it's greater
+                              ;; than the register
+                              "\C-x\C-k\C-ra>\C-r"
+                              ))
+  (kmacro-tests-should-insert "0124"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-equal-01 ()
+  "`kmacro-quit-counter-equal' stops macro if counter is equal to prefix"
+  (kmacro-tests-simulate-command '(kmacro-set-counter 5))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ;; Stop if the counter is at 0
+                              "\C-x\C-k\C-q="
+                              ))
+  (kmacro-tests-should-insert "5432"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 1 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-equal-02 ()
+  "`kmacro-quit-counter-equal' stops macro if counter is equal to prefix"
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Stop if the counter is at 5
+                              "\C-u5\C-x\C-k\C-q="
+                              ))
+  (kmacro-tests-should-insert "0123"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 4 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-equal-03 ()
+  "`kmacro-quit-counter-equal' stops macro if counter is equal to prefix"
+  (kmacro-tests-simulate-command '(kmacro-set-counter 5))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ;; Stop if the counter is at 0
+                              "\C-u\C-x\C-k\C-q="
+                              ))
+  (kmacro-tests-should-insert "5432"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 1 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-equal-04 ()
+  "`kmacro-quit-counter-equal' stops macro if counter is equal to prefix"
+  (kmacro-tests-simulate-command '(kmacro-set-counter 4))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ;; Stop if the counter is at -1
+                              "\C-u-\C-x\C-k\C-q="
+                              ))
+  (kmacro-tests-should-insert "4321"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 0 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-less ()
+  "`kmacro-quit-counter-less' stops macro if counter is less than prefix"
+  (kmacro-tests-simulate-command '(kmacro-set-counter 8))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Stop if the counter is less than 5
+                              "\C-u5\C-x\C-k\C-q<"
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ))
+  (kmacro-tests-should-insert "8765"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 4 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-greater ()
+  "`kmacro-quit-counter-greater' stops macro if counter is greater than prefix"
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Stop if the counter is greater than 4
+                              "\C-u4\C-x\C-k\C-q>"
+                              ))
+  (kmacro-tests-should-insert "0123"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 4 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+
 (kmacro-tests-deftest kmacro-tests-end-call-macro-prefix-args ()
   "kmacro-end-call-macro changes behavior based on prefix arg."
   ;; "Record" two macros.

--=-=-=
Content-Type: text/plain

-- 
Alex.

--=-=-=--



------------=_1717308182-24150-0
Content-Type: message/rfc822
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Received: (at 61549-done) by debbugs.gnu.org; 2 Jun 2024 06:02:22 +0000
Received: from localhost ([127.0.0.1]:57691 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1sDeIQ-0006G7-Bz
	for submit <at> debbugs.gnu.org; Sun, 02 Jun 2024 02:02:22 -0400
Received: from eggs.gnu.org ([209.51.188.92]:37490)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1sDeIN-0006Fj-Kb
 for 61549-done <at> debbugs.gnu.org; Sun, 02 Jun 2024 02:02:20 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1sDeI4-0005ss-As; Sun, 02 Jun 2024 02:02:00 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=oX8AyfuyZsniIgQqRSenLn/eeOtijeNXz2nZ0585/vE=; b=BlNTA56pMari
 iLvv4kMsrvyGNUX2Eu6rJcU2WIURl8+gXVFgsJhFjNOopU3f21j7H3BhnKnPz11FqPhsEdtk0ULJ6
 PHEePaWf34fvyruOkYVZ9Ns4cDROEWX1ZW4C15qNuTeSM0myR45em4MjV5/NiLq8yQlFNOx58PHk2
 lJ25URCwlGuMsT7BT4qI0gTiXZ4Pja395d5RGEBdgWqHyfo2+HWSzFGkdxklaJYEita79kvInSugc
 +tGnfGndQQ6E9i1rIt2aqcEB//o3EFMVQ2mesZbC5V/n9VaP1ktK9NauzHSsRJbM4Hczp9RfgCpUC
 5SCQLUPQbv6Volubz5w6Zw==;
Date: Sun, 02 Jun 2024 09:01:56 +0300
Message-Id: <861q5fopbf.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Alex Bochannek <alex@HIDDEN>
In-Reply-To: <m2cyp1tszt.fsf@HIDDEN> (message from Alex Bochannek on
 Fri, 31 May 2024 17:19:02 -0700)
Subject: Re: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions
References: <m2a61ef2i2.fsf@HIDDEN> <83sff41zgm.fsf@HIDDEN>
 <m2lekuo1os.fsf@HIDDEN> <83fsb2xhzp.fsf@HIDDEN>
 <m2a60qwnwu.fsf@HIDDEN> <m2jzjl1jsw.fsf@HIDDEN>
 <86ed9t5btc.fsf@HIDDEN> <m2cyp1tszt.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 61549-done
Cc: michael_heerdegen@HIDDEN, larsi@HIDDEN, monnier@HIDDEN,
 61549-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Alex Bochannek <alex@HIDDEN>
> Cc: monnier@HIDDEN,  larsi@HIDDEN,  61549 <at> debbugs.gnu.org,
>   Michael Heerdegen <michael_heerdegen@HIDDEN>
> Date: Fri, 31 May 2024 17:19:02 -0700
> 
> Thanks for the reminder of the other review comments. I went through
> those and addressed them.
> 
> I am attaching the changes to:
>   NEWS
>   kmacro.el
>   kmacro-tests.el
> 
> I hope this is the last iteration, but please let me know if there are
> stylistic or implementation issues.

Thanks.  The patches are okay, but they didn't apply cleanly, so I
needed to apply by hand.  Please in the future send the patches in the
form of "git format-patch", which will make it easier to install.

I'm therefore closing this bug.  Thank you for working on this.


------------=_1717308182-24150-0--


Message sent:


MIME-Version: 1.0
X-Mailer: MIME-tools 5.505 (Entity 5.505)
X-Loop: help-debbugs@HIDDEN
From: help-debbugs@HIDDEN (GNU bug Tracking System)
To: Alex Bochannek <alex@HIDDEN>
Subject: bug#61549: closed (Re: bug#61549: 30.0.50; [PATCH] New keyboard
 macro counter functions)
Message-ID: <handler.61549.D61549.171730814224067.notifdone <at> debbugs.gnu.org>
References: <861q5fopbf.fsf@HIDDEN> <m2a61ef2i2.fsf@HIDDEN>
X-Gnu-PR-Message: they-closed 61549
X-Gnu-PR-Package: emacs
X-Gnu-PR-Keywords: patch
Reply-To: 61549 <at> debbugs.gnu.org
Date: Sun, 02 Jun 2024 06:03:02 +0000
Content-Type: multipart/mixed; boundary="----------=_1717308182-24150-1"

This is a multi-part message in MIME format...

------------=_1717308182-24150-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset="utf-8"

Your bug report

#61549: 30.0.50; [PATCH] New keyboard macro counter functions

which was filed against the emacs package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 61549 <at> debbugs.gnu.org.

--=20
61549: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D61549
GNU Bug Tracking System
Contact help-debbugs@HIDDEN with problems

------------=_1717308182-24150-1
Content-Type: message/rfc822
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Received: (at 61549-done) by debbugs.gnu.org; 2 Jun 2024 06:02:22 +0000
Received: from localhost ([127.0.0.1]:57691 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1sDeIQ-0006G7-Bz
	for submit <at> debbugs.gnu.org; Sun, 02 Jun 2024 02:02:22 -0400
Received: from eggs.gnu.org ([209.51.188.92]:37490)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1sDeIN-0006Fj-Kb
 for 61549-done <at> debbugs.gnu.org; Sun, 02 Jun 2024 02:02:20 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1sDeI4-0005ss-As; Sun, 02 Jun 2024 02:02:00 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=oX8AyfuyZsniIgQqRSenLn/eeOtijeNXz2nZ0585/vE=; b=BlNTA56pMari
 iLvv4kMsrvyGNUX2Eu6rJcU2WIURl8+gXVFgsJhFjNOopU3f21j7H3BhnKnPz11FqPhsEdtk0ULJ6
 PHEePaWf34fvyruOkYVZ9Ns4cDROEWX1ZW4C15qNuTeSM0myR45em4MjV5/NiLq8yQlFNOx58PHk2
 lJ25URCwlGuMsT7BT4qI0gTiXZ4Pja395d5RGEBdgWqHyfo2+HWSzFGkdxklaJYEita79kvInSugc
 +tGnfGndQQ6E9i1rIt2aqcEB//o3EFMVQ2mesZbC5V/n9VaP1ktK9NauzHSsRJbM4Hczp9RfgCpUC
 5SCQLUPQbv6Volubz5w6Zw==;
Date: Sun, 02 Jun 2024 09:01:56 +0300
Message-Id: <861q5fopbf.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Alex Bochannek <alex@HIDDEN>
In-Reply-To: <m2cyp1tszt.fsf@HIDDEN> (message from Alex Bochannek on
 Fri, 31 May 2024 17:19:02 -0700)
Subject: Re: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions
References: <m2a61ef2i2.fsf@HIDDEN> <83sff41zgm.fsf@HIDDEN>
 <m2lekuo1os.fsf@HIDDEN> <83fsb2xhzp.fsf@HIDDEN>
 <m2a60qwnwu.fsf@HIDDEN> <m2jzjl1jsw.fsf@HIDDEN>
 <86ed9t5btc.fsf@HIDDEN> <m2cyp1tszt.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 61549-done
Cc: michael_heerdegen@HIDDEN, larsi@HIDDEN, monnier@HIDDEN,
 61549-done <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Alex Bochannek <alex@HIDDEN>
> Cc: monnier@HIDDEN,  larsi@HIDDEN,  61549 <at> debbugs.gnu.org,
>   Michael Heerdegen <michael_heerdegen@HIDDEN>
> Date: Fri, 31 May 2024 17:19:02 -0700
> 
> Thanks for the reminder of the other review comments. I went through
> those and addressed them.
> 
> I am attaching the changes to:
>   NEWS
>   kmacro.el
>   kmacro-tests.el
> 
> I hope this is the last iteration, but please let me know if there are
> stylistic or implementation issues.

Thanks.  The patches are okay, but they didn't apply cleanly, so I
needed to apply by hand.  Please in the future send the patches in the
form of "git format-patch", which will make it easier to install.

I'm therefore closing this bug.  Thank you for working on this.


------------=_1717308182-24150-1
Content-Type: message/rfc822
Content-Disposition: inline
Content-Transfer-Encoding: 7bit

Received: (at submit) by debbugs.gnu.org; 16 Feb 2023 08:18:44 +0000
Received: from localhost ([127.0.0.1]:34785 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pSZTW-0001Dt-Pv
	for submit <at> debbugs.gnu.org; Thu, 16 Feb 2023 03:18:44 -0500
Received: from lists.gnu.org ([209.51.188.17]:46082)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <alex@HIDDEN>) id 1pSZTR-0001Dh-C8
 for submit <at> debbugs.gnu.org; Thu, 16 Feb 2023 03:18:41 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <alex@HIDDEN>)
 id 1pSZTQ-0004nY-Qt
 for bug-gnu-emacs@HIDDEN; Thu, 16 Feb 2023 03:18:36 -0500
Received: from ns.lapseofthought.com ([50.0.39.240]
 helo=mail.lapseofthought.com)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <alex@HIDDEN>)
 id 1pSZTM-0005b6-Q9
 for bug-gnu-emacs@HIDDEN; Thu, 16 Feb 2023 03:18:36 -0500
Received: from awb-mbp.local (c-73-92-249-246.hsd1.ca.comcast.net
 [73.92.249.246])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by mail.lapseofthought.com (Postfix) with ESMTPSA id 4PHSVG0nlwz3pf5q
 for <bug-gnu-emacs@HIDDEN>; Thu, 16 Feb 2023 00:17:26 -0800 (PST)
Authentication-Results: ORIGINATING;
 auth=pass smtp.auth=alex smtp.mailfrom=alex@HIDDEN
From: Alex Bochannek <alex@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 30.0.50; [PATCH] New keyboard macro counter functions
Date: Thu, 16 Feb 2023 00:17:25 -0800
Message-ID: <m2a61ef2i2.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
Received-SPF: pass client-ip=50.0.39.240; envelope-from=alex@HIDDEN;
 helo=mail.lapseofthought.com
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

--=-=-=
Content-Type: text/plain

Hello!

I have been working on blog posts about keyboard macros and found that
it would be useful to have comparison functions for the keyboard macro
counter.

I implemented two functions to load and save macro counter values from
and to number registers; three comparison functions of the macro counter
with a number register that conditionally increment the counter; three
comparison functions of the macro counter with a prefix that terminate
the macro execution. This simplifies handling multiple counters and
conditional macro termination.

I am attaching the changes to:
  emacs.texi
  kmacro.texi
  NEWS
  kmacro.el
  kmacro-tests.el

I hope this functionality is useful and that I followed the coding and
style standards.

Thanks!

	Advanced keyboard macro counter commands for register
	integration and conditional macro termination

	* doc/emacs/emacs.texi (Top):
	Document advanced keyboard macro counter commands.

	* doc/emacs/kmacro.texi (Keyboard Macros, Keyboard Macro Counter):
	Document advanced keyboard macro counter commands.

	* etc/NEWS:
	Document advanced keyboard macro counter commands.

	* lisp/kmacro.el (kmacro-keymap, kmacro-reg-load-counter)
	(kmacro-reg-save-counter, kmacro-reg-add-counter-equal)
	(kmacro-reg-add-counter-equal, kmacro-reg-add-counter-less)
	(kmacro-reg-add-counter-greater, kmacro-reg-add-counter)
	(kmacro-quit-counter-equal, kmacro-quit-counter-less)
	(kmacro-quit-counter-greater, kmacro-quit-counter):
	Add advanced keyboard macro counter commands to kmacro keymap.
	Implement advanced keyboard macro counter commands.

	* test/lisp/kmacro-tests.el (kmacro-tests-test-reg-load)
	(kmacro-tests-test-reg-save)
	(kmacro-tests-test-reg-add-counter-equal-01)
	(kmacro-tests-test-reg-add-counter-equal-02)
	(kmacro-tests-test-reg-add-counter-equal-03)
	(kmacro-tests-test-reg-add-counter-equal-04)
	(kmacro-tests-test-reg-add-counter-less)
	(kmacro-tests-test-reg-add-counter-greater)
	(kmacro-tests-test-quit-counter-equal-01)
	(kmacro-tests-test-quit-counter-equal-02)
	(kmacro-tests-test-quit-counter-equal-03)
	(kmacro-tests-test-quit-counter-equal-04)
	(kmacro-tests-test-quit-counter-less)
	(kmacro-tests-test-quit-counter-greater):
	Implement unit tests for advanced keyboard macro counter
	commands.

--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/doc/emacs/emacs.texi b/doc/emacs/emacs.texi
index 7071ea44edd..2584dce8d44 100644
--- a/doc/emacs/emacs.texi
+++ b/doc/emacs/emacs.texi
@@ -434,6 +434,7 @@ Top
 * Basic Keyboard Macro::     Defining and running keyboard macros.
 * Keyboard Macro Ring::      Where previous keyboard macros are saved.
 * Keyboard Macro Counter::   Inserting incrementing numbers in macros.
+* Advanced Macro Counter::   Advanced macro counter commands.
 * Keyboard Macro Query::     Making keyboard macros do different things each
                                 time.
 * Save Keyboard Macro::      Giving keyboard macros names; saving them in

--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/doc/emacs/kmacro.texi b/doc/emacs/kmacro.texi
index fc1402b489d..27c84c0f96f 100644
--- a/doc/emacs/kmacro.texi
+++ b/doc/emacs/kmacro.texi
@@ -35,6 +35,7 @@ Keyboard Macros
 * Basic Keyboard Macro::     Defining and running keyboard macros.
 * Keyboard Macro Ring::      Where previous keyboard macros are saved.
 * Keyboard Macro Counter::   Inserting incrementing numbers in macros.
+* Advanced Macro Counter::   Advanced macro counter commands.
 * Keyboard Macro Query::     Making keyboard macros do different things each
                                time.
 * Save Keyboard Macro::      Giving keyboard macros names; saving them in
@@ -364,6 +365,123 @@ Keyboard Macro Counter
 keyboard macro counter.  @xref{Number Registers}.  For most purposes,
 it is simpler to use a keyboard macro counter.
 
+@node Advanced Macro Counter
+@section Advanced Macro Counter Commands
+
+  The counter associated with a keyboard macro is sufficient in most
+cases.  If additional counters are required for a macro, registers can
+be used and these advanced macro counter commands simplify the
+interaction between the two.  Additional commands are provided to
+terminate a macro after a predefined number of runs.
+
+
+@table @kbd
+@item C-x C-k C-r l
+Load the value of a number register into the macro counter
+(@code{kmacro-reg-load-counter}).
+@item C-x C-k C-r s
+Save the value of the macro counter to a number register
+(@code{kmacro-reg-save-counter}).
+@end table
+
+@table @kbd
+@item C-x C-k C-r a =
+Compare if the macro counter is equal to the value of a register and
+increment the counter if it is (@code{kmacro-reg-add-counter-equal}).
+@item C-x C-k C-r a <
+Compare if the macro counter is less than the value of a register and
+increment the counter if it is (@code{kmacro-reg-add-counter-less}).
+@item C-x C-k C-r a >
+Compare if the macro counter is greater than the value of a register
+and increment the counter if it is
+(@code{kmacro-reg-add-counter-greater}).
+@end table
+
+@table @kbd
+@item C-x C-k C-q =
+Compare if the macro counter is equal to the prefix and terminate the
+macro if it is (@code{kmacro-quit-counter-equal}).
+@item C-x C-k C-q <
+Compare if the macro counter is less than the prefix and terminate the
+macro if it is (@code{kmacro-quit-counter-less}).
+@item C-x C-k C-q >
+Compare if the macro counter is greater than the prefix and terminate
+the macro if it is (@code{kmacro-quit-counter-greater}).
+@end table
+
+@findex kmacro-reg-load-counter
+@kindex C-x C-k C-r l
+@findex kmacro-reg-save-counter
+@kindex C-x C-k C-r s
+  The command @kbd{C-x C-k C-r l} (@code{kmacro-reg-load-counter})
+prompts for the register name from which to load a number into the
+macro counter.  The command @kbd{C-x C-k C-r s}
+(@code{kmacro-reg-save-counter}) prompts for the register name into
+which to save the macro counter's value.  Both @kbd{C-x C-k C-r l}
+(@code{kmacro-reg-load-counter}) and @kbd{C-x C-k C-r s}
+(@code{kmacro-reg-save-counter}) show a preview of the registers by
+default.  @xref{Registers}.  Both commands can be used during or
+outside a keyboard macro definition.
+
+@findex kmacro-reg-add-counter-equal
+@kindex C-x C-k C-r a =
+@findex kmacro-reg-add-counter-less
+@kindex C-x C-k C-r a <
+@findex kmacro-reg-add-counter-greater
+@kindex C-x C-k C-r a >
+  The @kbd{C-x C-k C-r a =} (@code{kmacro-reg-add-counter-equal}),
+@kbd{C-x C-k C-r a <} (@code{kmacro-reg-add-counter-less}), and
+@kbd{C-x C-k C-r a >} (@code{kmacro-reg-add-counter-greater}) commands
+all follow the same pattern.  During keyboard macro definition, the
+command prompts for a register name (with preview by default), the
+contents of which will be compared with the macro counter's value.  If
+the counter is equal to (@code{=}), less than (@code{<}), or greater
+than (@code{>}) the number register's contents, the counter will be
+incremented by the numeric prefix or one if no prefix was given to the
+command.
+
+  For example,
+
+@example
+C-u 2 C-x C-k C-r a > N
+@end example
+
+@noindent
+compares the counter with the contents of register @code{N} and if the
+counter is greater than that, increases it by two.
+
+@findex kmacro-quit-counter-equal
+@kindex C-x C-k C-q =
+@findex kmacro-quit-counter-less
+@kindex C-x C-k C-q <
+@findex kmacro-quit-counter-greater
+@kindex C-x C-k C-q >
+  Finally, the @kbd{C-x C-k C-q =} (@code{kmacro-quit-counter-equal}),
+@kbd{C-x C-k C-q <} (@code{kmacro-quit-counter-less}), and @kbd{C-x
+C-k C-q >} (@code{kmacro-quit-counter-greater}) commands compare the
+macro counter with the prefix given and terminate the execution of the
+macro, if the comparison succeeds.  If no numeric prefix or only
+@code{C-u} are given, the counter will be compared with zero.  The
+macro is terminated using the @code{keyboard-quit} function.  Using
+this command to exit from a macro that has been called by another
+macro is not supported, the entire executing macro is terminated.
+
+  The quit commands can be used to construct the equivalent of a
+@code{while}-loop. This example will stop after ten executions
+assuming the starting value for the macro counter is the default zero.
+
+@example
+C-u 10 C-x C-k C-q = C-x C-k C-i @key{RET}
+@end example
+
+  With the default counter value of zero, the macro called with a
+prefix of @code{C-u C-u} to execute sixteen times, will stop after ten
+iterations.  The counter values that have been inserted will be from 0
+to 9.  If the counter starts out a different value below ten, it will
+still stop at ten, because the counter does not actually count macro
+executions, but is incremented explicitly by the @code{C-x C-k C-i}
+command.
+
 @node Keyboard Macro Query
 @section Executing Macros with Variations

--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/etc/NEWS b/etc/NEWS
index 4fbe09e0541..d5a3ebb1df5 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -187,6 +187,25 @@ This command adds a docstring comment to the current defun.  If a
 comment already exists, point is only moved to the comment.  It is
 bound to 'C-c C-d' in 'go-ts-mode'.
 
+** Kmacro
+
++++
+*** New Advanced Macro Counter functions.
+New commands have been added to to implement advanced macro counter
+functions.
+
+The commands 'C-x C-k C-r l' and 'C-x C-k C-r s' load and save the
+macro counter from a to a number register respectively.
+
+The commands 'C-x C-k C-r a =', 'C-x C-k C-r a <', and
+'C-x C-k C-r a >' compare the macro counter with the contents of a
+number register and increment the counter by a prefix if the
+comparison succeeds.
+
+The commands 'C-x C-k C-q =', 'C-x C-k C-q <', and 'C-x C-k C-q >'
+compare the macro counter with a prefix and terminate the macro if the
+comparison succeeds.
+
 
 * New Modes and Packages in Emacs 30.1
 
--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/lisp/kmacro.el b/lisp/kmacro.el
index 94d8794bd23..e7c3f75efd0 100644
--- a/lisp/kmacro.el
+++ b/lisp/kmacro.el
@@ -183,10 +183,18 @@ kmacro-keymap
   "C-l"  #'kmacro-call-ring-2nd-repeat
 
   ;; macro counter
-  "C-f"  #'kmacro-set-format
-  "C-c"  #'kmacro-set-counter
-  "C-i"  #'kmacro-insert-counter
-  "C-a"  #'kmacro-add-counter
+  "C-f"     #'kmacro-set-format
+  "C-c"     #'kmacro-set-counter
+  "C-i"     #'kmacro-insert-counter
+  "C-a"     #'kmacro-add-counter
+  "C-r l"   #'kmacro-reg-load-counter
+  "C-r s"   #'kmacro-reg-save-counter
+  "C-r a =" #'kmacro-reg-add-counter-equal
+  "C-r a <" #'kmacro-reg-add-counter-less
+  "C-r a >" #'kmacro-reg-add-counter-greater
+  "C-q ="   #'kmacro-quit-counter-equal
+  "C-q <"   #'kmacro-quit-counter-less
+  "C-q >"   #'kmacro-quit-counter-greater
 
   ;; macro editing
   "C-e"  #'kmacro-edit-macro-repeat
@@ -347,6 +355,89 @@ kmacro-add-counter
     (kmacro-display-counter)))
 
 
+(defun kmacro-reg-load-counter (register)
+  "Load the value of a register into `kmacro-counter'"
+  (interactive
+   (list (register-read-with-preview "Load register to counter: ")))
+  (let ((register-val (get-register register)))
+    (when (numberp register-val)
+     (setq kmacro-counter register-val))))
+
+
+(defun kmacro-reg-save-counter (register)
+  "Save the value of `kmacro-counter' to a register"
+  (interactive
+   (list (register-read-with-preview "Save counter to register: ")))
+  (set-register register kmacro-counter))
+
+
+(defun kmacro-reg-add-counter-equal (&optional arg)
+  "Increment counter by ARG if it is equal to register value"
+  (interactive "p")
+  (let
+      ((register (register-read-with-preview "Compare counter to register: ")))
+    (kmacro-reg-add-counter '= register arg)))
+
+
+(defun kmacro-reg-add-counter-less (&optional arg)
+  "Increment counter by ARG if it is less than register value"
+  (interactive "p")
+  (let
+      ((register (register-read-with-preview "Compare counter to register: ")))
+    (kmacro-reg-add-counter '< register arg)))
+
+
+(defun kmacro-reg-add-counter-greater (&optional arg)
+  "Increment counter by ARG if it is greater than register value"
+  (interactive "p")
+  (let
+      ((register (register-read-with-preview "Compare counter to register: ")))
+    (kmacro-reg-add-counter '> register arg)))
+
+
+(defun kmacro-reg-add-counter (func register &optional arg)
+  "Increment the counter by ARG if (FUNC kmacro-counter REGISTER-VALUE)
+is true.
+With no ARG, ARG is set to 1"
+  (let ((register-val (get-register register))
+        (arg (if (null arg) 1 arg)))
+    (when (apply func (list kmacro-counter register-val))
+      (setq current-prefix-arg nil)
+      (kmacro-add-counter arg))))
+
+
+(defun kmacro-quit-counter-equal (&optional arg)
+  "Quit the keyboard macro if the counter is equal to ARG"
+  (interactive "P")
+  (kmacro-quit-counter '= arg))
+
+
+(defun kmacro-quit-counter-less (&optional arg)
+  "Quit the keyboard macro if the counter is less than ARG"
+  (interactive "P")
+  (kmacro-quit-counter '< arg))
+
+
+(defun kmacro-quit-counter-greater (&optional arg)
+  "Quit the keyboard macro if the counter is greater than ARG"
+    (interactive "P")
+    (kmacro-quit-counter '> arg))
+
+
+(defun kmacro-quit-counter (func &optional arg)
+  "Quit the keyboard macro if (FUNC kmacro-counter ARG) is true.
+With \\[universal-argument] or no ARG, ARG is set to 0"
+  (when kmacro-initial-counter-value
+      (setq kmacro-counter kmacro-initial-counter-value
+	    kmacro-initial-counter-value nil))
+  (let ((arg
+	 (cond ((or (consp arg) (null arg)) 0)
+	       ((eq '- arg) -1)
+	       (t arg))))
+    (when (apply func (list kmacro-counter arg))
+      (keyboard-quit))))
+
+
 (defun kmacro-loop-setup-function ()
   "Function called prior to each iteration of macro."
   ;; Restore macro counter format to initial format, so it is ok to change

--=-=-=
Content-Type: text/x-patch
Content-Disposition: inline

diff --git a/test/lisp/kmacro-tests.el b/test/lisp/kmacro-tests.el
index 551fd8b60fc..e30681db539 100644
--- a/test/lisp/kmacro-tests.el
+++ b/test/lisp/kmacro-tests.el
@@ -275,6 +275,220 @@ kmacro-tests-start-insert-counter-appends-to-macro
     ;;  Verify that the recording state has changed.
     (should (equal defining-kbd-macro 'append))))
 
+
+(kmacro-tests-deftest kmacro-tests-test-reg-load ()
+  "`kmacro-reg-load-counter' loads the value of register to into the counter"
+  (set-register ?\C-r 4) ;; Should be safe as a register name
+  (kmacro-tests-simulate-command '(kmacro-set-counter 1))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              "\C-x\C-k\C-i"
+                              ;; Load from register
+                              "\C-x\C-k\C-rl\C-r"
+                              ))
+  (kmacro-tests-should-insert "1245"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 2)))
+    (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-save ()
+  "`kmacro-reg-save-counter' save the counter to a register"
+  (set-register ?\C-r nil) ;; Should be safe as a register name
+  (kmacro-tests-simulate-command '(kmacro-set-counter 1))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Save to register
+                              "\C-x\C-k\C-rs\C-r"
+                              ;; Add to counter
+                              "\C-u2\C-x\C-k\C-a"
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Insert register
+                              "\C-xri\C-r"
+                              ))
+  (kmacro-tests-should-insert "142586"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 2)))
+  (set-register ?\C-r nil))
+
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-equal-01 ()
+  "`kmacro-reg-add-counter-equal' increments counter if equal to register"
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Increment counter if it matches
+                              "\C-x\C-k\C-ra=\C-r"
+                              ))
+  (kmacro-tests-should-insert "0134"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-equal-02 ()
+  "`kmacro-reg-add-counter-equal' increments counter if equal to register"
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Add two to counter if it matches
+                              "\C-u2\C-x\C-k\C-ra=\C-r"
+                              ))
+  (kmacro-tests-should-insert "0145"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-equal-03 ()
+  "`kmacro-reg-add-counter-equal' increments counter if equal to register"
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Add four to counter if it matches
+                              "\C-u\C-x\C-k\C-ra=\C-r"
+                              ))
+  (kmacro-tests-should-insert "0167"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-equal-04 ()
+  "`kmacro-reg-add-counter-equal' increments counter if equal to register"
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Decrement counter if it matches
+                              "\C-u-\C-x\C-k\C-ra=\C-r"
+                              ))
+  (kmacro-tests-should-insert "0111"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-less ()
+  "`kmacro-reg-add-counter-less' increments counter if less than register"
+  (set-register ?\C-r 6) ;; Should be safe as a register name
+  (kmacro-tests-simulate-command '(kmacro-set-counter 8))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Decrement counter if it's
+                              ;; less than the register
+                              "\C-u-1\C-x\C-k\C-ra<\C-r"
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ))
+  (kmacro-tests-should-insert "8764"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+    (set-register ?\C-r nil))
+
+(kmacro-tests-deftest kmacro-tests-test-reg-add-counter-greater ()
+  "`kmacro-reg-add-counter-greater' increments counter if greater than register"
+  (set-register ?\C-r 2) ;; Should be safe as a register name
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Increment counter if it's greater
+                              ;; than the register
+                              "\C-x\C-k\C-ra>\C-r"
+                              ))
+  (kmacro-tests-should-insert "0124"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (set-register ?\C-r nil))
+
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-equal-01 ()
+  "`kmacro-quit-counter-equal' stops macro if counter is equal to prefix"
+  (kmacro-tests-simulate-command '(kmacro-set-counter 5))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ;; Stop if the counter is at 0
+                              "\C-x\C-k\C-q="
+                              ))
+  (kmacro-tests-should-insert "5432"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 1 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-equal-02 ()
+  "`kmacro-quit-counter-equal' stops macro if counter is equal to prefix"
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Stop if the counter is at 5
+                              "\C-u5\C-x\C-k\C-q="
+                              ))
+  (kmacro-tests-should-insert "0123"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 4 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-equal-03 ()
+  "`kmacro-quit-counter-equal' stops macro if counter is equal to prefix"
+  (kmacro-tests-simulate-command '(kmacro-set-counter 5))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ;; Stop if the counter is at 0
+                              "\C-u\C-x\C-k\C-q="
+                              ))
+  (kmacro-tests-should-insert "5432"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 1 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-equal-04 ()
+  "`kmacro-quit-counter-equal' stops macro if counter is equal to prefix"
+  (kmacro-tests-simulate-command '(kmacro-set-counter 4))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ;; Stop if the counter is at -1
+                              "\C-u-\C-x\C-k\C-q="
+                              ))
+  (kmacro-tests-should-insert "4321"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 0 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-less ()
+  "`kmacro-quit-counter-less' stops macro if counter is less than prefix"
+  (kmacro-tests-simulate-command '(kmacro-set-counter 8))
+  (kmacro-tests-define-macro (vconcat
+                              ;; Stop if the counter is less than 5
+                              "\C-u5\C-x\C-k\C-q<"
+                              ;; Insert and decrement counter
+                              "\C-u-\C-x\C-k\C-i"
+                              ))
+  (kmacro-tests-should-insert "8765"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 4 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+(kmacro-tests-deftest kmacro-tests-test-quit-counter-greater ()
+  "`kmacro-quit-counter-greater' stops macro if counter is greater than prefix"
+  (kmacro-tests-define-macro (vconcat
+                              ;; Insert and increment counter
+                              "\C-x\C-k\C-i"
+                              ;; Stop if the counter is greater than 4
+                              "\C-u4\C-x\C-k\C-q>"
+                              ))
+  (kmacro-tests-should-insert "0123"
+    (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 4)))
+  (should (condition-case abort
+              (should (= 4 kmacro-counter))
+              (kmacro-tests-simulate-command '(kmacro-end-or-call-macro 1))
+            (quit abort))))
+
+
 (kmacro-tests-deftest kmacro-tests-end-call-macro-prefix-args ()
   "kmacro-end-call-macro changes behavior based on prefix arg."
   ;; "Record" two macros.

--=-=-=
Content-Type: text/plain

-- 
Alex.

--=-=-=--



------------=_1717308182-24150-1--


Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions
Resent-From: Michael Heerdegen <michael_heerdegen@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Sun, 02 Jun 2024 23:34:01 +0000
Resent-Message-ID: <handler.61549.B61549.171737122610880 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 61549
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Alex Bochannek <alex@HIDDEN>
Cc: Eli Zaretskii <eliz@HIDDEN>, larsi@HIDDEN, 61549 <at> debbugs.gnu.org, monnier@HIDDEN
Received: via spool by 61549-submit <at> debbugs.gnu.org id=B61549.171737122610880
          (code B ref 61549); Sun, 02 Jun 2024 23:34:01 +0000
Received: (at 61549) by debbugs.gnu.org; 2 Jun 2024 23:33:46 +0000
Received: from localhost ([127.0.0.1]:50007 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1sDuhu-0002pQ-08
	for submit <at> debbugs.gnu.org; Sun, 02 Jun 2024 19:33:46 -0400
Received: from mout.web.de ([217.72.192.78]:49713)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <michael_heerdegen@HIDDEN>) id 1sDuhr-0002p1-72
 for 61549 <at> debbugs.gnu.org; Sun, 02 Jun 2024 19:33:45 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de;
 s=s29768273; t=1717371191; x=1717975991;
 i=michael_heerdegen@HIDDEN;
 bh=zXxG8SF8k0W5TH2OMzLGeQQFmzFgIIL2CO1JmZZsJSU=;
 h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date:
 Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding:
 content-type:date:from:message-id:mime-version:reply-to:subject:
 to;
 b=jKHqDVVX1BzgedNKgHPWIIdhspfaJ3vVpa3KZN9tetJR2o4+nxXvAYC8hdpbECz7
 43CXyRXgB3XS5zkN/JcYXvPXOaWjjTIj71S6m7UWe/pDdYQRQOrdmSJx0RItZdeP/
 UC4BRWpQ+fwkvmVlRyhOzCoyf/0J79xfzu9RV6xE5kbZZFTobF+M1+l9YGvrOkOg7
 DBi2S1AvngpvoklkKtX8EKi53k3aR9o4BsEiwi9g0wKfySCX0o/XQ4Hr159wzCPKL
 M/IF9Br2odFmHnYgsD7cap29gRmv7L6MBWb6pvZ77lXEaQ2lL81eNV+VTpMugRfXg
 X/iPN1lWOFH0f8lVJw==
X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6
Received: from drachen.dragon ([84.59.210.113]) by smtp.web.de (mrweb106
 [213.165.67.124]) with ESMTPSA (Nemesis) id 1MoNZC-1spVct0siu-00omYx; Mon, 03
 Jun 2024 01:33:11 +0200
From: Michael Heerdegen <michael_heerdegen@HIDDEN>
In-Reply-To: <m2cyp1tszt.fsf@HIDDEN> (Alex Bochannek's message of "Fri, 
 31 May 2024 17:19:02 -0700")
References: <m2a61ef2i2.fsf@HIDDEN> <83sff41zgm.fsf@HIDDEN>
 <m2lekuo1os.fsf@HIDDEN> <83fsb2xhzp.fsf@HIDDEN>
 <m2a60qwnwu.fsf@HIDDEN> <m2jzjl1jsw.fsf@HIDDEN>
 <86ed9t5btc.fsf@HIDDEN> <m2cyp1tszt.fsf@HIDDEN>
Date: Mon, 03 Jun 2024 01:33:54 +0200
Message-ID: <87h6eahqcd.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Provags-ID: V03:K1:zb/l0k5KYTCiPlDWf7AxuhgItwkG3MOJtUBKeKCuLOnSOvB1ccz
 x6BzVeoWTYw8m/7GOHpzMFK/4FBJ8yldOcM22tQXMtFOpG6s+6RE1lA7h8PzVDvvV3PpEuy
 J5FMbmYtO9x7M7Ph6JqQ2oK5FsmNNQABTyrcfey0oezMFY7qinebP9qRt1c2pdcIEzEcoAT
 HCwVm7wpEajPT4vGB6RFg==
X-Spam-Flag: NO
UI-OutboundReport: notjunk:1;M01:P0:iXVYXYCgQjQ=;/VeolLUYKl1Tt4zpBT8KWzB9Lg/
 btkk2GM9jGuLu7lMEMUCzWsiAnBgqVQVn9jHAaxmKaZQIf6b1CsUF9q2kIkx9q82VgIoK47RI
 hSyMtAsGSYQDlrzxlTLRhdkSvqqOLmD2ZZrm9wPHK04DWN7+nJNfKcQ4fOekR3DCIcVMNJLm2
 /fF5V4PGHLNu7YVNnlINovh7o2iY/BYwTdhFV+16NFtF37LxBDm9P9ra2A0p3DF4WdPFWbxXK
 GCZOktnEMbpXDenPEkP2csP/WDofkE1G8UqrvPgqfIti0JOGhBUFUywuexZtcrdZURm/ozUcV
 Uv6ory6VkAQ4f/mYi0/AzcDgEZ5Sg0FF9WlcCEuFLszEmntPzhut5f+csgTr4zVYs0zeOYv2J
 2dnfshbwjmJ8CL42KG0VS1TNDWyXAlMkNnkuzrE7gn0pXSrpFzij6VcrlkfbvDe/JBWjxu4fq
 qo+R5wMd8cO+wnBfor8XgZnEgp0wJBWPbmIZQBj1rBc6R9Tms0Kjvovli0RQYTI5F3oG46nAh
 JyoV/BCMbHlQ1fRhz0gT2o8c7OHs6TxVVKd664Tg4aXuMJLFFxVpWB7IMELVvj6wEmE0Limal
 nGEvnyGKbKqkgh6o5qpMrlHy5A32wj2rSEGfn8wWXLqCXRnR7uC77hG5FdFJE+2ltTAw4Hog+
 6aID6GegrHZaTTuXexHR0lKpjz8gb3e6jtRrwqfgEv7sU5Ihaf7Hc1Wjzqa9WmC066rdUmn0q
 BPIQmRy8aS1o7JuoeD/0fGIIANDU6wI/ofRvqdzN6qf8E1N4AL7Ni7r6hzv3NB3cN/iyO+5lN
 Ie2gkr0/tDsdfaamV5E3BTLQUoxjbaYjvXmlOlQ1YL5pY=
X-Spam-Score: -0.7 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Alex Bochannek <alex@HIDDEN> writes:

> I hope this is the last iteration, but please let me know if there are
> stylistic or implementation issues.

Sorry, but some more small questions from my side (please excuse my
ignorance, I'm not a heavy user of keyboard macros so if any question
doesn't make sense maybe I'm just on a wrong track):

(1) "kmacro-add-counter" and related functions... I wonder why these are
not named "kmacro-increase-counter" - would that not be better
understandable?  I mean, AFAIU, you do not add a counter but add
something to an (or "the") counter.  But maybe I misunderstand.

(2) `kmacro-reg-load-counter': I think I would expect a `user-error'
being raised when the operation fails.  Unless that would get in the
way in your use case (break recording or so, dunno).

(3) I actually don't understand the usage of the
`kmacro-reg-add-counter-*' named functions (did you, Eli?).  An example
would maybe help.

In addition I want to say the suggested manual additions are useful.
Would it make sense to add at least some parts to the file header or
some pieces to the docstrings, or as comments?


Thanks,

Michael.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Mon, 03 Jun 2024 11:51:02 +0000
Resent-Message-ID: <handler.61549.B61549.171741544129089 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 61549
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Michael Heerdegen <michael_heerdegen@HIDDEN>
Cc: 61549 <at> debbugs.gnu.org, larsi@HIDDEN, monnier@HIDDEN, alex@HIDDEN
Received: via spool by 61549-submit <at> debbugs.gnu.org id=B61549.171741544129089
          (code B ref 61549); Mon, 03 Jun 2024 11:51:02 +0000
Received: (at 61549) by debbugs.gnu.org; 3 Jun 2024 11:50:41 +0000
Received: from localhost ([127.0.0.1]:33187 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1sE6D2-0007Z6-Mu
	for submit <at> debbugs.gnu.org; Mon, 03 Jun 2024 07:50:41 -0400
Received: from eggs.gnu.org ([209.51.188.92]:48368)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1sE6Cx-0007YE-30
 for 61549 <at> debbugs.gnu.org; Mon, 03 Jun 2024 07:50:38 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1sE5wO-0001wS-2d; Mon, 03 Jun 2024 07:33:28 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=0R2woz82yrdYzgs/dpe+LPPaq+MZ8Pe1hj3wmGwkrMw=; b=g2/YIT18/KuW
 a/Cblg93DtCmXjLAwmUxJC+ml+nq6qD7b+93g+iTQJpZwhZIaxz9DJyDThqSGAFF8TJL2ZSxk3g/z
 rESzlAnO8ccpS26/h9PvP1yehCpxzhNHbYtjEdSo2T1o0ii1/6k1n1lJcCOHK+eSPEvjUEb62/fRE
 B77xlE3MBRfUEdsdswu+xq7ZqFt/hY5IefpwB2Q5MTjkKfsBy5tBUbNzFDIXtQziSWvZNkqMjL30J
 O0TeafEhQUh9UhVQ7Rrx9sRkYu8drVYkp+Gu4aC3alqP4OhpRsmtkBsT+3ZjCO1OHAwgF5rfGKNcq
 5deE9p00LQU/diSZpkzUvQ==;
Date: Mon, 03 Jun 2024 14:33:20 +0300
Message-Id: <864jaamfb3.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <87h6eahqcd.fsf@HIDDEN> (message from Michael Heerdegen on Mon,
 03 Jun 2024 01:33:54 +0200)
References: <m2a61ef2i2.fsf@HIDDEN> <83sff41zgm.fsf@HIDDEN>
 <m2lekuo1os.fsf@HIDDEN> <83fsb2xhzp.fsf@HIDDEN>
 <m2a60qwnwu.fsf@HIDDEN> <m2jzjl1jsw.fsf@HIDDEN>
 <86ed9t5btc.fsf@HIDDEN> <m2cyp1tszt.fsf@HIDDEN>
 <87h6eahqcd.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Michael Heerdegen <michael_heerdegen@HIDDEN>
> Cc: Eli Zaretskii <eliz@HIDDEN>,  larsi@HIDDEN,
>   monnier@HIDDEN,  61549 <at> debbugs.gnu.org
> Date: Mon, 03 Jun 2024 01:33:54 +0200
> 
> Alex Bochannek <alex@HIDDEN> writes:
> 
> > I hope this is the last iteration, but please let me know if there are
> > stylistic or implementation issues.
> 
> Sorry, but some more small questions from my side (please excuse my
> ignorance, I'm not a heavy user of keyboard macros so if any question
> doesn't make sense maybe I'm just on a wrong track):

Thanks, but please in the future try to chime in earlier, while the
patches are still being discussed.  I intentionally wait for at least
a week before doing something, and in this case the thread was going
on for much longer.

> (1) "kmacro-add-counter" and related functions... I wonder why these are
> not named "kmacro-increase-counter" - would that not be better
> understandable?  I mean, AFAIU, you do not add a counter but add
> something to an (or "the") counter.  But maybe I misunderstand.

If we want to rename this, IMO kmacro-add-to-counter is a better name.

> (2) `kmacro-reg-load-counter': I think I would expect a `user-error'
> being raised when the operation fails.  Unless that would get in the
> way in your use case (break recording or so, dunno).

No opinion here, as I don't use those, either.

> (3) I actually don't understand the usage of the
> `kmacro-reg-add-counter-*' named functions (did you, Eli?).  An example
> would maybe help.

Did you read the doc string before or after I install the changes?

> In addition I want to say the suggested manual additions are useful.
> Would it make sense to add at least some parts to the file header or
> some pieces to the docstrings, or as comments?

No, I think these are sufficiently obscure to not be in the manual.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions
Resent-From: Michael Heerdegen <michael_heerdegen@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 04 Jun 2024 00:57:02 +0000
Resent-Message-ID: <handler.61549.B61549.17174625765004 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 61549
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Eli Zaretskii <eliz@HIDDEN>
Cc: 61549 <at> debbugs.gnu.org, larsi@HIDDEN, monnier@HIDDEN, alex@HIDDEN
Received: via spool by 61549-submit <at> debbugs.gnu.org id=B61549.17174625765004
          (code B ref 61549); Tue, 04 Jun 2024 00:57:02 +0000
Received: (at 61549) by debbugs.gnu.org; 4 Jun 2024 00:56:16 +0000
Received: from localhost ([127.0.0.1]:55998 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1sEITI-0001Ie-CP
	for submit <at> debbugs.gnu.org; Mon, 03 Jun 2024 20:56:16 -0400
Received: from mout.web.de ([212.227.15.3]:58785)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <michael_heerdegen@HIDDEN>) id 1sEITG-0001IP-9i
 for 61549 <at> debbugs.gnu.org; Mon, 03 Jun 2024 20:56:15 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de;
 s=s29768273; t=1717462538; x=1718067338;
 i=michael_heerdegen@HIDDEN;
 bh=+i0qR6dYgDk1AAVLumlgb5UkLAt2PcH331N6WYOvDNE=;
 h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date:
 Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding:
 content-type:date:from:message-id:mime-version:reply-to:subject:
 to;
 b=euRz/N5cj8w13yO8ZPakKjtGIzneg9Bxv3Dvvsp7g0tK9Y70z+9kjopOzqjA4S+C
 gXEdFUS2a/kzMw+2GAmxqafJ11MK8udfdvGzMsjEnpy8dUtRoQv6eHJ0ITRkV1Y/B
 TLB0Bp38DKDBEAFDdVEbb1r0UcZhNJuvfHO2CpK522YH2CFAP3n7jRsuE1aZh7BPR
 K4D2yBWBNIAPINMhMvmhFQ++baWTfgLITV0y/niy/RrK4bTAf6IabifG9O87d370v
 oTwtz+NN6rWwEWlXGiCxLpSfFxi0HncAlY6Eb+8WlOZcequojkrK8/dkN1IuTBkyP
 TAQwJKiqfIfgUC0ZGg==
X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6
Received: from drachen.dragon ([84.59.210.113]) by smtp.web.de (mrweb006
 [213.165.67.108]) with ESMTPSA (Nemesis) id 1Mho04-1sjFZC1Tfs-00db4e; Tue, 04
 Jun 2024 02:55:38 +0200
From: Michael Heerdegen <michael_heerdegen@HIDDEN>
In-Reply-To: <864jaamfb3.fsf@HIDDEN> (Eli Zaretskii's message of "Mon, 03 Jun
 2024 14:33:20 +0300")
References: <m2a61ef2i2.fsf@HIDDEN> <83sff41zgm.fsf@HIDDEN>
 <m2lekuo1os.fsf@HIDDEN> <83fsb2xhzp.fsf@HIDDEN>
 <m2a60qwnwu.fsf@HIDDEN> <m2jzjl1jsw.fsf@HIDDEN>
 <86ed9t5btc.fsf@HIDDEN> <m2cyp1tszt.fsf@HIDDEN>
 <87h6eahqcd.fsf@HIDDEN> <864jaamfb3.fsf@HIDDEN>
Date: Tue, 04 Jun 2024 02:56:21 +0200
Message-ID: <871q5da5l6.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Provags-ID: V03:K1:qJNKPD0+Bo7/1/ivp1q8uDk0nY4voNravONuxEgmUR98DsWF66r
 wvzYaf/23tCkwYBf+upK9bnMa/HJwDPxoWiy/POhQtTnamPs+KZ1Wut3XLfRXZgLFGXaMDI
 rML/vgWkF+MViz7Wl0OPhkw2MT6P2vOJPMjPeLRqxq4hhoJGXKkQYh+1/p/9jwYkNYHmZZi
 Nqevs0RU4Or5dQTxn3GgQ==
X-Spam-Flag: NO
UI-OutboundReport: notjunk:1;M01:P0:IBhYvQgr44w=;gtjkNsa0gXthx5Ii+uP5wH0y9tN
 P6Ugr5oFG9d+3nWrXZEgJUc0G4jb5NtyAk1ifbUsYJFKvu6lvZ8p2WThGlH2sDOG+dsLgmawe
 +Aa4feRgCmJywRvrqXrhuBYx1/47/XlliIM0PihJvAh2R+sW53ri5ltaqRDVkOu/Z1wYp0X7o
 4HrWxXs737+nX39YgrBVypi2jLbRUGBM3EYcSAnHzSY8FvTttI54AxqEcBLKzZYjykmB6+V1d
 cGFtJ1utyY6sEJhbYud3i4IvuOxqtLWF9BZTO9eqwcN6d36jFn9g7wSqglUyrAQhyeGD+7DN2
 7JIW4Cwyrcr7Xxlh0x1TznZhqOyYYs3Csro5Y5z6phF8K4qWPZ4sx9jdAKimFvDkbn270yvR6
 BJOJVjdVn0ablT5uxuvBo+/C7Ah6i2T62uf6AlGDABf+c9RqIlWhYy3/a3qHp68ABX7hcdCbX
 5tRNz8SVm9wT5Q3sIZu3arOv5INvlUHpQKSvtXbD4/nBwG5YJPDZ7eFVMVjw/hXKxir6ulz0d
 xqggLkyrkzqcSeFqYrmDcd35+cmfKx33Aoku+TrwJbkBVHdpVlCRKkXI49cRmGw4vdXb+T4xM
 lPChZUOaY9ZMcQlGE+yzKfdjh6fx4th9R9Y0gkODVga/hBHuAhJZEsv8pGziZnP7zOV1gWkp/
 EhoLVTXz+Tfz/LBJPzPvun8baSohEL+2TdJ7HYXkItVvyGUJ4eSLMzql1e/CBUrDyvAR6PFLQ
 Wa/wGcSMnkal+D4JqPB7aSJ3nsFKOG/pMHyoRh6mamZRUk2GBF4bNgzEWV7Li2HBHdf+eHIbJ
 JRDkS1kKy1bkPxrjkzlGId5+L7CzJlx8ygLH15r6rsFnI=
X-Spam-Score: -0.7 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.7 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

> Thanks, but please in the future try to chime in earlier [...]

Sure - I'm sorry that I failed this time.

> > (1) "kmacro-add-counter" and related functions... I wonder why these are
> > not named "kmacro-increase-counter" [...]

> If we want to rename this, IMO kmacro-add-to-counter is a better name.

Sounds reasonable.

> > (3) I actually don't understand the usage of the
> > `kmacro-reg-add-counter-*' named functions (did you, Eli?).  An example
> > would maybe help.
>
> Did you read the doc string before or after I install the changes?

Both times in this case, actually.  My question was more about how this
is supposed to be used, not what it does.  Maybe it's obvious when one
uses kmacros often.

> > In addition I want to say the suggested manual additions are useful.
> > Would it make sense to add at least some parts to the file header or
> > some pieces to the docstrings, or as comments?
>
> No, I think these are sufficiently obscure to not be in the manual.

I agree - but the focus here was on the second sentence.


Thanks,

Michael.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions
Resent-From: Drew Adams <drew.adams@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 04 Jun 2024 01:42:01 +0000
Resent-Message-ID: <handler.61549.B61549.171746529710394 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 61549
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Michael Heerdegen <michael_heerdegen@HIDDEN>, Eli Zaretskii <eliz@HIDDEN>
Cc: "alex@HIDDEN" <alex@HIDDEN>, "larsi@HIDDEN" <larsi@HIDDEN>, "monnier@HIDDEN" <monnier@HIDDEN>, "61549 <at> debbugs.gnu.org" <61549 <at> debbugs.gnu.org>
Received: via spool by 61549-submit <at> debbugs.gnu.org id=B61549.171746529710394
          (code B ref 61549); Tue, 04 Jun 2024 01:42:01 +0000
Received: (at 61549) by debbugs.gnu.org; 4 Jun 2024 01:41:37 +0000
Received: from localhost ([127.0.0.1]:56018 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1sEJBB-0002ha-09
	for submit <at> debbugs.gnu.org; Mon, 03 Jun 2024 21:41:37 -0400
Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:54306)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <drew.adams@HIDDEN>) id 1sEJB8-0002hM-5R
 for 61549 <at> debbugs.gnu.org; Mon, 03 Jun 2024 21:41:35 -0400
Received: from pps.filterd (m0246617.ppops.net [127.0.0.1])
 by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id
 453KihXd027120; Tue, 4 Jun 2024 01:41:14 GMT
DKIM-Signature: v=1;  a=rsa-sha256;  c=relaxed/relaxed;
  d=oracle.com;  h=cc:content-transfer-encoding:content-type:date:from:in-reply-to:message-id:mime-version:references:subject:to; s=corp-2023-11-20; bh=C7Ca1ln6dNtrlj8KX5ar+jq4S9sCyIBc6hrXE55YCM8=; b=T0bisLJOQdlxhSCE1cPvr4R44l2mdQ6UbYEBsShZ5T7bv+vZFCwZNEoZHlduLMX7VrKB 3Fr02D5IgpBE6tz/J37y514K7+KbukWkccMPPSlvTd/KEb/VURh/iiwl6kvubjBby1Q2 O9TnyvhEYtMoItgIbkZc/DbfpiE5bvtM6VYqTZbdhIGHByTQzOuaR84Ycgl7p3zic2go jnCxJUpJvf7EtQZBL9MSHuUNwbUymp1LJpnLWf7qGPs2LQXAq7bKI9Cdj0YbTJAA4IDq P5iBFH0hjszajb3gYpQNDFFsnbXLafh+MpOS0hL8y6eUcKkpxZ0zwVAkiLDFEpAqOVQ9 Rw== 
Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com
 (phxpaimrmta02.appoci.oracle.com [147.154.114.232])
 by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3yfv6u3xm3-1
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);
 Tue, 04 Jun 2024 01:41:14 +0000
Received: from pps.filterd
 (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1])
 by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.19/8.17.1.19)
 with ESMTP id 453NHEKa015588; Tue, 4 Jun 2024 01:41:13 GMT
Received: from nam10-mw2-obe.outbound.protection.outlook.com
 (mail-mw2nam10lp2044.outbound.protection.outlook.com [104.47.55.44])
 by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id
 3ygrjbpepr-1
 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK);
 Tue, 04 Jun 2024 01:41:13 +0000
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
 b=byk8un1EZffpcehUg6uBkEh9LTyCHZlq8WxD5aTxcUYPJTaA4Ssl8Es9Y9/8upN0isulMfP/RGkbZ2WPM5cBY3GMuEkSV3u9bfA4redH47/ZkNoPZYucJjw89R4RvnuRjktUfkvc0wnvRDklskAhzIKKGHOL4aYCitJyy0RRm3rwq15UgLt05fRzCVo1ZZbPs4vG40xdua5szgFaR1FfOwJE0+iUVImU+MWjVT5qW6fa7Qa3dvF4AmSujsATYI3hYq2exBsUxNy1Zp9sTV1hUJCJ+7s16HLe9rLHHRLovfNrcnJ1pfuE8Xn6/7AE2jTbuBcA64E2pAq+HbpBw5vPDQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; 
 s=arcselector9901;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
 bh=C7Ca1ln6dNtrlj8KX5ar+jq4S9sCyIBc6hrXE55YCM8=;
 b=neywP8iO/wf3fUGWCaU9rGFLOZ0eI8z6rzy0gT11LM1Wu52YilAMxCmnb5YKsmvmVCF0fNornRBWjs+Aq9MAzzJhDsf1ni7LOEZ5AJe/ddsCer2EAjd50QDBlmCswR7d24/RL0iBbOUyiSJwPqyCtScyvcc59bB9d2xbL5mluNX/KHLR7aCaZPj6kAfnxrxquDKBZ4Kb1Y5o3jjGMt1qpaYPmJRZFUO5165s+kS9BdRjKndVpYjzE5URkCXiXjPhADKheRkSWI/61D6BDGeffgGtyfdbTkjNHMLhrt5pp/kbVMeOXsodfjfbKW9AV8hrCGRMzePaKezh+7Q6iA7IVg==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
 smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com;
 dkim=pass header.d=oracle.com; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com;
 h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
 bh=C7Ca1ln6dNtrlj8KX5ar+jq4S9sCyIBc6hrXE55YCM8=;
 b=jlDH3cJ0t8jbco8HQF5+ZI7gShY7kJbmbEsN/x5o0+791mZttwljf2qH/R6TYPZtaqDW/vwyFQaQfNP6C127yXZBbvxFk2EynFrjv18aKnnkZGwRpCi8G+4FfagSMS7nVYLDMTw+3axmwJFT1WzvAogRc/O9wzOS0KXsW+Mtw9Y=
Received: from SJ0PR10MB5488.namprd10.prod.outlook.com (2603:10b6:a03:37e::19)
 by CH0PR10MB4876.namprd10.prod.outlook.com (2603:10b6:610:c9::16)
 with Microsoft SMTP Server (version=TLS1_2,
 cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.24; Tue, 4 Jun
 2024 01:40:51 +0000
Received: from SJ0PR10MB5488.namprd10.prod.outlook.com
 ([fe80::b75a:ef76:884a:dd27]) by SJ0PR10MB5488.namprd10.prod.outlook.com
 ([fe80::b75a:ef76:884a:dd27%4]) with mapi id 15.20.7633.021; Tue, 4 Jun 2024
 01:40:51 +0000
From: Drew Adams <drew.adams@HIDDEN>
Thread-Topic: [External] : bug#61549: 30.0.50; [PATCH] New keyboard macro
 counter functions
Thread-Index: AQHatholfgHf5jLuFUK3h5ywWerUeLG208Pg
Date: Tue, 4 Jun 2024 01:40:51 +0000
Message-ID: <SJ0PR10MB5488A61F2916E16DACEC0171F3F82@HIDDEN>
References: <m2a61ef2i2.fsf@HIDDEN> <83sff41zgm.fsf@HIDDEN>
 <m2lekuo1os.fsf@HIDDEN> <83fsb2xhzp.fsf@HIDDEN>
 <m2a60qwnwu.fsf@HIDDEN> <m2jzjl1jsw.fsf@HIDDEN>
 <86ed9t5btc.fsf@HIDDEN> <m2cyp1tszt.fsf@HIDDEN>
 <87h6eahqcd.fsf@HIDDEN> <864jaamfb3.fsf@HIDDEN> <871q5da5l6.fsf@HIDDEN>
In-Reply-To: <871q5da5l6.fsf@HIDDEN>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: SJ0PR10MB5488:EE_|CH0PR10MB4876:EE_
x-ms-office365-filtering-correlation-id: 675e87b8-6dc6-45c7-235b-08dc84375dc6
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0; ARA:13230031|366007|376005|1800799015|38070700009;
x-microsoft-antispam-message-info: 6y8LUq++dyqSWGnqI5IBdkVzDLS6hJNZ8KFeEZPVmM0JnGU8h8HVx3f+2UyYSbkMlUFLFscDSNwND1zPyOmrvElmDsw2UwRNfrGvhaHz2tCEKt7oXAE0l1VMKKpUpdt8/8LMdlwYef/5metuwi5EHjUityrsQqYzEp7Y81xu+gUkoNcmsw5+52ZKAsxjwP9I3BFzMkZlC8rbk7508xeQKVCJhyPvO77Zaw47KDdnvJcJyqGLrIVnpANyG8f5CKAmO8XQA5xITfUTczv1qC4+q3VFVm8Ct+wzrJexdzQnszcNKC+OnFY/w57tzlkT13AlnBj9JnSPn51xSb7xTZOxLYiZjXRcicySQr9EUGwebXAlhSxZ8yfn7GeVqCkEeNzf3Pa7rzw5JDH3z+dSh2w+gY0JtwZkrKKNGapP1cZinfRwaJSh3vNYyqo8jJ2+GPFTZZozoXM7BDpuTS40aFaIqXNsnE6i0cXPr13G/t+a69teEpxv6fnEsgtv12mAIgCHZ/BaAgcQHtZuD3D6+rKQmNv14LrsFmctb3nXBL9LLzp+V+p1XWWipxhsO6a8XPiDfeozO96RhHgZjN9i16sbZTOwMgGZxjv1igMsjCF+s1zx4t3I57kEv7uCJSJkFHX9NM9GJle0dkWIYG4E3ZmNh6SuMX2PCc7rdAO1k07466t4FRxUcSQ4WZc64QBwEdQX6MaxkASUli86gzUnUbl9TCylRFx3Mras5ZbZnHkTfcIbNiHlND+kV74rL0j9eKSccAxVGff86E1jFu+MfICkXAXsAZ5ZXmcvHvfvaw2uVF5k0KAQ89ZkqvRw9PpBjO4ZLxcGRwBtV1dd5FsEWVIKnhm9CME5idRvkQ4+Re3GxN1kplBYB61wuPukkJ8U7/OcVrNvZ72TaUnAyCbjjDXHIZeHh5TffbeTAW8pSgi8hXCBqHp76Rp/84H0OpZmLO3dde4pqN1l6/I++Bk6D34C6CPPwpBBAYeFlFuhZMe/Yc1f+6lHd3Lx406ZCImu8aa+AjPNpCLyirjSbkR7jAzgq5VxH9blMOYRWlHKH8Gq5P8pKdFHh73QkszWjN7LY4l4Ntejdz5wPaycOIAR1VLctOsbECo7HgtSxzQTYUY0ulfScvLMDEmbEEhD+0u/XvVwbDaNaYchUlVLSnhb0uz6T5LbTboe3foWTtmzx/iA7YLkgnR9lfgKpfqw1M/DAquQQqA7bh541P6DlUMXpCXtTYw+GlW0BgwF3V3GppuRaMeBmOT6jOeGouQPVKjWL98t8eOOyGh/lZhdxbEonpNBVRrIjUEL+KKsw3XBlLO930nmfOkK37UiYdaexz5zQao2I8/abYWJmrrdT6W828ZtQg==
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
 IPV:NLI; SFV:NSPM; H:SJ0PR10MB5488.namprd10.prod.outlook.com; PTR:; CAT:NONE;
 SFS:(13230031)(366007)(376005)(1800799015)(38070700009); DIR:OUT; SFP:1101; 
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: eUrLMtOKbXz6rRCI1EBe9aPMWK8/kMa6L1fHTeh6M5MLg06jVGHapYmplGiI4IuokyBGQz5asvvR7NbWSsat62oWqFkEuvcHXGnZSb+ecrh/mqh9hzcwt7ZMYCWP7qWksUVWcLblCTeOjG+CF1mmKn9bp+n2tSTXnv4/3ouSo5szbQ+2DswsCm0dlpfUwL76pBW/QJEzF9JPSfqZ6Kvnoivg2pmt0CyBToJvYXuiG/0XPB6FGPxxIRCVlW9C4oMKwMc0u2Ez7jM3c6bjcDpPEJ1pEfeLtSy+JIr8MUfG3Mii6iXMcGhZnMw0aZhcmqaTckH9xehbLXp9ctIwX+VsaGDEjI+oJdMXET3yUF9r0lFB/NegcjAIKRrsjwPI3JL+bEzwLfjBNKkFtieHCDQbMc9K+gU0Vuyr+zVwt4tBk+mRhoHCT+sxBPGyslG2Umfh9DLIGZuJ7LNXbnEfIb3h4yO9z8FItUSp9q1vvHdu3Px/IJXI3REttxwIqchN6vqAcISDuap6Uw5+9DMpfXGpB6hiK9r53yNbplcm/E2XpQQlUZ0qgrLLxmwQpNGe8qRt3QFH/27TyEgOTTleKTkapIFyDXRASyhTWb1z3GMBTjRA/PL2BndkfoV++dCMM6pKUv/qAjRtvrSTjN7vQYHtavWp35Ozc0EavYyRkEc9UJ33R5E6GOB9UAQC3VzeLpzqRvokrWeViPq6XrLHJF2nLPHVknoBGjjrM4GfG2aC/mH6PfSXJMj+PKEIJUs5eog05kVjgpRfgUeZWZ0u0VruTotkA23LEeqtDg1UweKFUZmX2Kb4XerznIKw9mQo5quj+kxhOUOPmOuW2uUCZqZlbz1zt3fDhHIddCDUmUuCIFHNWwJeP2CZ5epbEYTeBvA0ibbVKnQd1E4IewPr46x+8CGEbQTOTgeH15NRGciv3eGhQ+V91DrYuTxfg25A3mXOazA5sxWsq0WIGaw15DFxaDBT5VIStWs7DpPHjqCmohIne5B9nrCxGHaad2hU+8kMYYFBMQxBOnYymIGkO2Xhk9cZXGG3XGZy/3k7IVwg+yI0hpGjBHHQCUegVHVYCP5oMzYaiacm6y+ZWMYmHt88tr3lTVfG1MvtNqUw2Tcdb3uooOBJE7X+5FsGc4xr3qnewbnMkTuzH68uo3OADyOo5HCMoUm5a0Oi6IdRvL//ccB/1H2hrJ+PfpTxh77w+GkzwGXQlaWrKfjW6g8kMoC+y0f73Lu8zPuEb/BRtQdIb9h/FECxctBngKKjwkUclRolMBzM0UUFbfZZMSXpTGrhA8RU/eO099oOwUIBnXBkg4HQYhJOGhKTvh6fLN5xgddnTWvDXxRM7AsxAitZflsAH+mu8MNjioMoKgS8PfEv7hx2JgHI0reKbtEfRhgMn/nN3PGV7qEGGx0TEo9pRwr7+mOFZr8yv8eC8dGxCAAkbu2NsB7iYIvKPzAYTAF6T6R+EzLRtjIrEShI+NZgofFalHrLvkm+JgeOBdbI2aIbZI4meBYK7O7WsprFruoYYKuHJed03AUPm1mKmMHb1pD1PnXQEfs/Re+DgOhLCIfcJNJZ9Dp7Rv9PPkTZ/VHlVpku
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1
X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: pRjgoZxI8UBaxVrYvh/eIQ6Q90HnCwzvCv6ny0tlAjfOn6X0KonXu5Injocv0yQ6GFQaKCVHow4tS12i7RlnOGf1EcWb3clpwIQcOtGQ6BDtR/X6NcBOBvPPZ+myuWUg6AVCbEL2l/iMc9AO1GqaCjs7b7Mui0w+3nJFVFY3H8LxoDshXL1CicVw5JlmjpAqgOAOqG00e4Y/PixIrJdR9BIWegTvamvocQUWdBrjjfnyYjKn0UjigZk2k2wM6BBjzceDKmY8aq81AwqBshGRXbC9pSAY+H3/M4+HuZtL7YURLKPb07+0G2gkIt0sDSAdUwKKZ6e7DP7jo4s0oAToH80E4tOrd4x+NwwvqIVN7mJEr+7zCOhNF2pXSQSGJNpKwNVh1tLk64rJx1EDfyYSSlHODf8I2jTei6QzdVG8nrbRGj3hWlGjCFMeGIEUqcSh2cW2+cJd5e9j7GmjC5OzmjLknw2v3+6ERZ1yDjAUYnhykaUk+afqPyobMdFiaNDzTGJVC9r2if0IeZekQP2mHy1xqlcrgeYCyQH+kVKX0f+b+vUL2eb8uG5FMX4WAG2qA0YmLpNyaS4CXhPdHC0YpuGZH4MKakEHl4GGy4l3oiE=
X-OriginatorOrg: oracle.com
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: SJ0PR10MB5488.namprd10.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: 675e87b8-6dc6-45c7-235b-08dc84375dc6
X-MS-Exchange-CrossTenant-originalarrivaltime: 04 Jun 2024 01:40:51.0750 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b
X-MS-Exchange-CrossTenant-mailboxtype: HOSTED
X-MS-Exchange-CrossTenant-userprincipalname: x213Irc4UZfCDE1R78H5Z3Gt1iF0oaADW5MADp/es6R25HrygxIqa3EfuVHQOebdFseFtahqUddzl5ZG1HrosA==
X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB4876
X-Proofpoint-Virus-Version: vendor=baseguard
 engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16
 definitions=2024-06-03_17,2024-05-30_01,2024-05-17_01
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999
 phishscore=0
 adultscore=0 bulkscore=0 spamscore=0 malwarescore=0 mlxscore=0
 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1
 engine=8.12.0-2405010000 definitions=main-2406040012
X-Proofpoint-ORIG-GUID: Q89rFPTjI0IC6aiV7eUh4iCCF1yBbGox
X-Proofpoint-GUID: Q89rFPTjI0IC6aiV7eUh4iCCF1yBbGox
X-Spam-Score: 0.0 (/)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> > > not named "kmacro-increase-counter" [...]
>=20
> > If we want to rename this, IMO kmacro-add-to-counter is a better name.
>=20
> Sounds reasonable.

kmacro-increment-counter (if that's what
"adding to" it means here)





Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions
Resent-From: Alex Bochannek <alex@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 04 Jun 2024 02:02:02 +0000
Resent-Message-ID: <handler.61549.B61549.171746651923670 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 61549
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Michael Heerdegen <michael_heerdegen@HIDDEN>
Cc: Eli Zaretskii <eliz@HIDDEN>, larsi@HIDDEN, 61549 <at> debbugs.gnu.org, monnier@HIDDEN
Received: via spool by 61549-submit <at> debbugs.gnu.org id=B61549.171746651923670
          (code B ref 61549); Tue, 04 Jun 2024 02:02:02 +0000
Received: (at 61549) by debbugs.gnu.org; 4 Jun 2024 02:01:59 +0000
Received: from localhost ([127.0.0.1]:56047 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1sEJUs-00069i-L5
	for submit <at> debbugs.gnu.org; Mon, 03 Jun 2024 22:01:58 -0400
Received: from ns.lapseofthought.com ([50.0.39.240]:22770
 helo=mail.lapseofthought.com)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <alex@HIDDEN>) id 1sEJUm-00069S-Mc
 for 61549 <at> debbugs.gnu.org; Mon, 03 Jun 2024 22:01:57 -0400
Received: from awb-mbp.local (c-24-23-131-202.hsd1.ca.comcast.net
 [24.23.131.202])
 (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
 (No client certificate requested)
 by mail.lapseofthought.com (Postfix) with ESMTPSA id 4VtYjF53mxz3pdD9;
 Mon,  3 Jun 2024 19:01:05 -0700 (PDT)
Authentication-Results: ORIGINATING;
 auth=pass smtp.auth=alex smtp.mailfrom=alex@HIDDEN
From: Alex Bochannek <alex@HIDDEN>
In-Reply-To: <871q5da5l6.fsf@HIDDEN> (Michael Heerdegen's message of "Tue, 04
 Jun 2024 02:56:21 +0200")
References: <m2a61ef2i2.fsf@HIDDEN> <83sff41zgm.fsf@HIDDEN>
 <m2lekuo1os.fsf@HIDDEN> <83fsb2xhzp.fsf@HIDDEN>
 <m2a60qwnwu.fsf@HIDDEN> <m2jzjl1jsw.fsf@HIDDEN>
 <86ed9t5btc.fsf@HIDDEN> <m2cyp1tszt.fsf@HIDDEN>
 <87h6eahqcd.fsf@HIDDEN> <864jaamfb3.fsf@HIDDEN>
 <871q5da5l6.fsf@HIDDEN>
Date: Mon, 03 Jun 2024 19:01:04 -0700
Message-ID: <m2zfs1wjof.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 1.3 (+)
X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 the administrator of that system for details.
 Content preview:  Michael, Eli, Michael Heerdegen <michael_heerdegen@HIDDEN>
 writes: > Eli Zaretskii <eliz@HIDDEN> writes: > >> Thanks, but please in
 the future try to chime in earlier [...] > > Sure - I'm sorry that I failed
 this time. > >> > (1) "kmacro-add-counter" and related fun [...] 
 Content analysis details:   (1.3 points, 10.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 0.0 T_SPF_TEMPERROR        SPF: test of record failed (temperror)
 -0.0 SPF_HELO_PASS          SPF: HELO matches SPF record
 1.0 FORGED_SPF_HELO        No description available.
 0.3 KHOP_HELO_FCRDNS       Relay HELO differs from its IP's reverse DNS
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Michael, Eli,

Michael Heerdegen <michael_heerdegen@HIDDEN> writes:

> Eli Zaretskii <eliz@HIDDEN> writes:
>
>> Thanks, but please in the future try to chime in earlier [...]
>
> Sure - I'm sorry that I failed this time.
>
>> > (1) "kmacro-add-counter" and related functions... I wonder why these are
>> > not named "kmacro-increase-counter" [...]
>
>> If we want to rename this, IMO kmacro-add-to-counter is a better name.
>
> Sounds reasonable.

I tried to make these function names descriptive and if there is
something more obvious, I am happy to rename them. (Also see below)

>> > (3) I actually don't understand the usage of the
>> > `kmacro-reg-add-counter-*' named functions (did you, Eli?).  An example
>> > would maybe help.
>>
>> Did you read the doc string before or after I install the changes?
>
> Both times in this case, actually.  My question was more about how this
> is supposed to be used, not what it does.  Maybe it's obvious when one
> uses kmacros often.

I had some examples in the documentation in the original patch proposal.
The first set of functions lets you easily construct loops that change
the stepping of the counter based on a register value, so something
like:

C-x C-k TAB C-x C-k C-r a > T RET C-u 20 C-x C-k C-q >

When register T is set to 10 this will loop in steps of one to 10, then
in steps of two until it quits at 20.

I think the functions may be somewhat inconsistent because the first set
takes a prefix as an increment value and a register name as an argument
whereas the second uses the prefix as a the comparison value. A more
general approach would be to allow numeric registers for both types of
functions.

The problem I was trying to solve was how to use keyboard macros to
auto-create lists of numbers. I have found it useful and I can see how
other people might discover other uses. I figured it's been a over a
year since I originally proposed this, let's get this in and improve it
as there is some usage.

>> > In addition I want to say the suggested manual additions are useful.
>> > Would it make sense to add at least some parts to the file header or
>> > some pieces to the docstrings, or as comments?
>>
>> No, I think these are sufficiently obscure to not be in the manual.
>
> I agree - but the focus here was on the second sentence.

-- 
Alex.




Message sent to bug-gnu-emacs@HIDDEN:


X-Loop: help-debbugs@HIDDEN
Subject: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions
Resent-From: Eli Zaretskii <eliz@HIDDEN>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
Resent-CC: bug-gnu-emacs@HIDDEN
Resent-Date: Tue, 04 Jun 2024 14:39:01 +0000
Resent-Message-ID: <handler.61549.B61549.171751189032488 <at> debbugs.gnu.org>
Resent-Sender: help-debbugs@HIDDEN
X-GNU-PR-Message: followup 61549
X-GNU-PR-Package: emacs
X-GNU-PR-Keywords: patch
To: Michael Heerdegen <michael_heerdegen@HIDDEN>
Cc: 61549 <at> debbugs.gnu.org, larsi@HIDDEN, monnier@HIDDEN, alex@HIDDEN
Received: via spool by 61549-submit <at> debbugs.gnu.org id=B61549.171751189032488
          (code B ref 61549); Tue, 04 Jun 2024 14:39:01 +0000
Received: (at 61549) by debbugs.gnu.org; 4 Jun 2024 14:38:10 +0000
Received: from localhost ([127.0.0.1]:56530 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1sEVIg-0008Ru-2v
	for submit <at> debbugs.gnu.org; Tue, 04 Jun 2024 10:38:10 -0400
Received: from eggs.gnu.org ([209.51.188.92]:52924)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1sEVId-0008RV-Rj
 for 61549 <at> debbugs.gnu.org; Tue, 04 Jun 2024 10:38:08 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1sEVIH-0005tJ-K4; Tue, 04 Jun 2024 10:37:45 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=w+EpAILdX6pRkBRF4Vx7uAEaw9VNFl/RC9AkstcLIYY=; b=U6CJTCLU8q9V
 TJJ48kpxHX9PA5TL4C/PjyYMDz483iF8lN0Sl1C5zoyNK8rSmgAhN/qhH/eaRLrra7PLHTEK9Vf9c
 yljVaXJyd0cYw1TrPExGbPsNk/HhWEOfz73nfJiR/QCjX0pR4ONeFGg4OEDMRwWLvJ15Chhxtx92y
 ckMWSrTT2fTQzEy4uHP3JXmHS3u9Wloo4XS5E/liO9ZWmFsT1v87fftc6khOpMgYjypBUaUkBu7A1
 JeLiCBPr7xOG17khiisXEAGfGv0ZqZpYrvZXXyYcCnHkxStmPRpqx4p1cB35h8kZo1akGV2Ft8Pqi
 Tr60Z26F6FWhDmNW3NcWuA==;
Date: Tue, 04 Jun 2024 17:37:39 +0300
Message-Id: <864ja8lqoc.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
In-Reply-To: <871q5da5l6.fsf@HIDDEN> (message from Michael Heerdegen on Tue,
 04 Jun 2024 02:56:21 +0200)
References: <m2a61ef2i2.fsf@HIDDEN> <83sff41zgm.fsf@HIDDEN>
 <m2lekuo1os.fsf@HIDDEN> <83fsb2xhzp.fsf@HIDDEN>
 <m2a60qwnwu.fsf@HIDDEN> <m2jzjl1jsw.fsf@HIDDEN>
 <86ed9t5btc.fsf@HIDDEN> <m2cyp1tszt.fsf@HIDDEN>
 <87h6eahqcd.fsf@HIDDEN> <864jaamfb3.fsf@HIDDEN> <871q5da5l6.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Michael Heerdegen <michael_heerdegen@HIDDEN>
> Cc: alex@HIDDEN,  larsi@HIDDEN,  monnier@HIDDEN,
>   61549 <at> debbugs.gnu.org
> Date: Tue, 04 Jun 2024 02:56:21 +0200
> 
> Eli Zaretskii <eliz@HIDDEN> writes:
> 
> > > In addition I want to say the suggested manual additions are useful.
> > > Would it make sense to add at least some parts to the file header or
> > > some pieces to the docstrings, or as comments?
> >
> > No, I think these are sufficiently obscure to not be in the manual.
> 
> I agree - but the focus here was on the second sentence.

Feel free to suggest patches for documentation, and TIA.





Last modified: Tue, 4 Jun 2024 14:45:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.