From unknown Fri Jun 20 07:14:10 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#61549 <61549@debbugs.gnu.org> To: bug#61549 <61549@debbugs.gnu.org> Subject: Status: 30.0.50; [PATCH] New keyboard macro counter functions Reply-To: bug#61549 <61549@debbugs.gnu.org> Date: Fri, 20 Jun 2025 14:14:10 +0000 retitle 61549 30.0.50; [PATCH] New keyboard macro counter functions reassign 61549 emacs submitter 61549 Alex Bochannek severity 61549 wishlist tag 61549 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Feb 16 03:18:44 2023 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 ) id 1pSZTW-0001Dt-Pv for submit@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 ) id 1pSZTR-0001Dh-C8 for submit@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 ) id 1pSZTQ-0004nY-Qt for bug-gnu-emacs@gnu.org; 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 ) id 1pSZTM-0005b6-Q9 for bug-gnu-emacs@gnu.org; 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 ; Thu, 16 Feb 2023 00:17:26 -0800 (PST) Authentication-Results: ORIGINATING; auth=pass smtp.auth=alex smtp.mailfrom=alex@bochannek.com From: Alex Bochannek To: bug-gnu-emacs@gnu.org Subject: 30.0.50; [PATCH] New keyboard macro counter functions Date: Thu, 16 Feb 2023 00:17:25 -0800 Message-ID: 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@bochannek.com; 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@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Fri Feb 17 03:14:00 2023 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 ) id 1pSvsW-0006TA-3o for submit@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 ) id 1pSvsR-0006Sr-2A for 61549@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 ) 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 ) 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@gnu.org> From: Eli Zaretskii To: Alex Bochannek , Stefan Monnier , Lars Ingebrigtsen In-Reply-To: (message from Alex Bochannek on Thu, 16 Feb 2023 00:17:25 -0800) Subject: Re: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions References: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61549 Cc: 61549@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Alex Bochannek > 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. From debbugs-submit-bounces@debbugs.gnu.org Sat Feb 18 20:59:21 2023 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 ) id 1pTYz3-0001oy-EM for submit@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 ) id 1pTYz1-0001op-97 for 61549@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@bochannek.com From: Alex Bochannek To: Eli Zaretskii Subject: Re: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions In-Reply-To: <83sff41zgm.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 17 Feb 2023 10:13:45 +0200") References: <83sff41zgm.fsf@gnu.org> Date: Sat, 18 Feb 2023 17:59:15 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 61549 Cc: Lars Ingebrigtsen , Stefan Monnier , 61549@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 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. From debbugs-submit-bounces@debbugs.gnu.org Sun Feb 19 01:54:39 2023 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 ) id 1pTdap-0001Yd-1F for submit@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 ) id 1pTdam-0001YN-FW for 61549@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 ) 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 ) 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@gnu.org> From: Eli Zaretskii To: Alex Bochannek In-Reply-To: (message from Alex Bochannek on Sat, 18 Feb 2023 17:59:15 -0800) Subject: Re: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions References: <83sff41zgm.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61549 Cc: larsi@gnus.org, monnier@iro.umontreal.ca, 61549@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Alex Bochannek > Cc: Stefan Monnier , Lars Ingebrigtsen > , 61549@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. From debbugs-submit-bounces@debbugs.gnu.org Sun Mar 05 22:37:31 2023 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 ) id 1pZ1fG-0004b8-By for submit@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 ) id 1pZ1fC-0004ay-Dx for 61549@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@bochannek.com From: Alex Bochannek To: Eli Zaretskii Subject: Re: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions In-Reply-To: <83fsb2xhzp.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 19 Feb 2023 08:54:34 +0200") References: <83sff41zgm.fsf@gnu.org> <83fsb2xhzp.fsf@gnu.org> Date: Sun, 05 Mar 2023 19:37:21 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 61549 Cc: larsi@gnus.org, monnier@iro.umontreal.ca, 61549@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 11 03:49:52 2023 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 ) id 1pauvI-0006ZM-D7 for submit@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 ) id 1pauvF-0006Z9-Td for 61549@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 ) 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 ) 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@gnu.org> From: Eli Zaretskii To: Alex Bochannek In-Reply-To: (message from Alex Bochannek on Sun, 05 Mar 2023 19:37:21 -0800) Subject: Re: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions References: <83sff41zgm.fsf@gnu.org> <83fsb2xhzp.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61549 Cc: larsi@gnus.org, monnier@iro.umontreal.ca, 61549@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Alex Bochannek > Cc: monnier@iro.umontreal.ca, larsi@gnus.org, 61549@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. From debbugs-submit-bounces@debbugs.gnu.org Sat Mar 11 19:19:24 2023 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 ) id 1pb9Qp-0004tZ-VK for submit@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 ) id 1pb9Ql-0004tI-Ju for 61549@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@web.de; 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 To: Alex Bochannek Subject: Re: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions In-Reply-To: (Alex Bochannek's message of "Sun, 05 Mar 2023 19:37:21 -0800") References: <83sff41zgm.fsf@gnu.org> <83fsb2xhzp.fsf@gnu.org> Date: Sun, 12 Mar 2023 01:19:01 +0100 Message-ID: <87o7oyizyi.fsf@web.de> 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-Debbugs-Envelope-To: 61549 Cc: Eli Zaretskii , larsi@gnus.org, 61549@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Alex Bochannek 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. From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 04 04:59:27 2023 Received: (at control) by debbugs.gnu.org; 4 Sep 2023 08:59:27 +0000 Received: from localhost ([127.0.0.1]:48581 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qd5Qd-0003Il-3y for submit@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 ) id 1qd5Qa-0003IX-Nu for control@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 ; 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 MIME-Version: 1.0 Date: Mon, 4 Sep 2023 01:59:18 -0700 Message-ID: Subject: control message for bug #61549 To: control@debbugs.gnu.org Content-Type: text/plain; charset="UTF-8" X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) severity 61549 wishlist quit From debbugs-submit-bounces@debbugs.gnu.org Wed May 22 19:59:20 2024 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 ) id 1s9vrc-0003VU-Gm for submit@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 ) id 1s9vrZ-0003VO-ES for 61549@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@bochannek.com From: Alex Bochannek To: Eli Zaretskii Subject: Re: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions In-Reply-To: (Alex Bochannek's message of "Sun, 05 Mar 2023 19:37:21 -0800") References: <83sff41zgm.fsf@gnu.org> <83fsb2xhzp.fsf@gnu.org> Date: Wed, 22 May 2024 16:57:51 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 61549 Cc: larsi@gnus.org, monnier@iro.umontreal.ca, 61549@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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. From debbugs-submit-bounces@debbugs.gnu.org Thu May 23 01:37:06 2024 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 ) id 1sA18U-0006nj-2W for submit@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 ) id 1sA18R-0006mu-PY for 61549@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 ) 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@gnu.org> From: Eli Zaretskii To: Alex Bochannek In-Reply-To: (message from Alex Bochannek on Wed, 22 May 2024 16:57:51 -0700) Subject: Re: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions References: <83sff41zgm.fsf@gnu.org> <83fsb2xhzp.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61549 Cc: Michael Heerdegen , larsi@gnus.org, monnier@iro.umontreal.ca, 61549@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Alex Bochannek > Cc: monnier@iro.umontreal.ca, larsi@gnus.org, 61549@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. From debbugs-submit-bounces@debbugs.gnu.org Fri May 31 20:20:53 2024 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 ) id 1sDCUO-0005jY-Kn for submit@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 ) id 1sDCUI-0005jM-MH for 61549@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@bochannek.com From: Alex Bochannek To: Eli Zaretskii Subject: Re: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions In-Reply-To: <86ed9t5btc.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 23 May 2024 08:36:47 +0300") References: <83sff41zgm.fsf@gnu.org> <83fsb2xhzp.fsf@gnu.org> <86ed9t5btc.fsf@gnu.org> Date: Fri, 31 May 2024 17:19:02 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 61549 Cc: Michael Heerdegen , larsi@gnus.org, monnier@iro.umontreal.ca, 61549@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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 writes: >> From: Alex Bochannek >> Cc: monnier@iro.umontreal.ca, larsi@gnus.org, 61549@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. --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 02 02:02:22 2024 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 ) id 1sDeIQ-0006G7-Bz for submit@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 ) id 1sDeIN-0006Fj-Kb for 61549-done@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 ) 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@gnu.org> From: Eli Zaretskii To: Alex Bochannek In-Reply-To: (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: <83sff41zgm.fsf@gnu.org> <83fsb2xhzp.fsf@gnu.org> <86ed9t5btc.fsf@gnu.org> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61549-done Cc: michael_heerdegen@web.de, larsi@gnus.org, monnier@iro.umontreal.ca, 61549-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Alex Bochannek > Cc: monnier@iro.umontreal.ca, larsi@gnus.org, 61549@debbugs.gnu.org, > Michael Heerdegen > 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. From debbugs-submit-bounces@debbugs.gnu.org Sun Jun 02 19:33:46 2024 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 ) id 1sDuhu-0002pQ-08 for submit@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 ) id 1sDuhr-0002p1-72 for 61549@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@web.de; 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 To: Alex Bochannek Subject: Re: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions In-Reply-To: (Alex Bochannek's message of "Fri, 31 May 2024 17:19:02 -0700") References: <83sff41zgm.fsf@gnu.org> <83fsb2xhzp.fsf@gnu.org> <86ed9t5btc.fsf@gnu.org> Date: Mon, 03 Jun 2024 01:33:54 +0200 Message-ID: <87h6eahqcd.fsf@web.de> 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-Debbugs-Envelope-To: 61549 Cc: Eli Zaretskii , larsi@gnus.org, 61549@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Alex Bochannek 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. From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 03 07:50:41 2024 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 ) id 1sE6D2-0007Z6-Mu for submit@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 ) id 1sE6Cx-0007YE-30 for 61549@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 ) 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@gnu.org> From: Eli Zaretskii To: Michael Heerdegen In-Reply-To: <87h6eahqcd.fsf@web.de> (message from Michael Heerdegen on Mon, 03 Jun 2024 01:33:54 +0200) Subject: Re: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions References: <83sff41zgm.fsf@gnu.org> <83fsb2xhzp.fsf@gnu.org> <86ed9t5btc.fsf@gnu.org> <87h6eahqcd.fsf@web.de> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61549 Cc: 61549@debbugs.gnu.org, larsi@gnus.org, monnier@iro.umontreal.ca, alex@bochannek.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Michael Heerdegen > Cc: Eli Zaretskii , larsi@gnus.org, > monnier@iro.umontreal.ca, 61549@debbugs.gnu.org > Date: Mon, 03 Jun 2024 01:33:54 +0200 > > Alex Bochannek 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. From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 03 20:56:16 2024 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 ) id 1sEITI-0001Ie-CP for submit@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 ) id 1sEITG-0001IP-9i for 61549@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@web.de; 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 To: Eli Zaretskii Subject: Re: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions In-Reply-To: <864jaamfb3.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 03 Jun 2024 14:33:20 +0300") References: <83sff41zgm.fsf@gnu.org> <83fsb2xhzp.fsf@gnu.org> <86ed9t5btc.fsf@gnu.org> <87h6eahqcd.fsf@web.de> <864jaamfb3.fsf@gnu.org> Date: Tue, 04 Jun 2024 02:56:21 +0200 Message-ID: <871q5da5l6.fsf@web.de> 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-Debbugs-Envelope-To: 61549 Cc: 61549@debbugs.gnu.org, larsi@gnus.org, monnier@iro.umontreal.ca, alex@bochannek.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Eli Zaretskii 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. From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 03 21:41:37 2024 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 ) id 1sEJBB-0002ha-09 for submit@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 ) id 1sEJB8-0002hM-5R for 61549@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: =?UTF-8?Q?v=3D1; _a=3Drsa-sha256; _c=3Drelaxed/relaxed; _d=3Doracle.com; _h?= =?UTF-8?Q?=3Dcc:content-transfer-encoding:content-type:date:from:in-reply?= =?UTF-8?Q?-to:message-id:mime-version:references:subject:to;_s=3Dcorp-202?= =?UTF-8?Q?3-11-20;_bh=3DC7Ca1ln6dNtrlj8KX5ar+jq4S9sCyIBc6hrXE55YCM8=3D;_b?= =?UTF-8?Q?=3DT0bisLJOQdlxhSCE1cPvr4R44l2mdQ6UbYEBsShZ5T7bv+vZFCwZNEoZHldu?= =?UTF-8?Q?LMX7VrKB_3Fr02D5IgpBE6tz/J37y514K7+KbukWkccMPPSlvTd/KEb/VURh/ii?= =?UTF-8?Q?wl6kvubjBby1Q2_O9TnyvhEYtMoItgIbkZc/DbfpiE5bvtM6VYqTZbdhIGHByTQ?= =?UTF-8?Q?zOuaR84Ycgl7p3zic2go_jnCxJUpJvf7EtQZBL9MSHuUNwbUymp1LJpnLWf7qGP?= =?UTF-8?Q?s2LQXAq7bKI9Cdj0YbTJAA4IDq_P5iBFH0hjszajb3gYpQNDFFsnbXLafh+MpOS?= =?UTF-8?Q?0hL8y6eUcKkpxZ0zwVAkiLDFEpAqOVQ9_Rw=3D=3D_?= 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 To: Michael Heerdegen , Eli Zaretskii Subject: RE: [External] : bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions 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: References: <83sff41zgm.fsf@gnu.org> <83fsb2xhzp.fsf@gnu.org> <86ed9t5btc.fsf@gnu.org> <87h6eahqcd.fsf@web.de> <864jaamfb3.fsf@gnu.org> <871q5da5l6.fsf@web.de> In-Reply-To: <871q5da5l6.fsf@web.de> 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: =?us-ascii?Q?6y8LUq++dyqSWGnqI5IBdkVzDLS6hJNZ8KFeEZPVmM0JnGU8h8HVx3f+2UyY?= =?us-ascii?Q?SbkMlUFLFscDSNwND1zPyOmrvElmDsw2UwRNfrGvhaHz2tCEKt7oXAE0l1VM?= =?us-ascii?Q?KKpUpdt8/8LMdlwYef/5metuwi5EHjUityrsQqYzEp7Y81xu+gUkoNcmsw5+?= =?us-ascii?Q?52ZKAsxjwP9I3BFzMkZlC8rbk7508xeQKVCJhyPvO77Zaw47KDdnvJcJyqGL?= =?us-ascii?Q?rIVnpANyG8f5CKAmO8XQA5xITfUTczv1qC4+q3VFVm8Ct+wzrJexdzQnszcN?= =?us-ascii?Q?KC+OnFY/w57tzlkT13AlnBj9JnSPn51xSb7xTZOxLYiZjXRcicySQr9EUGwe?= =?us-ascii?Q?bXAlhSxZ8yfn7GeVqCkEeNzf3Pa7rzw5JDH3z+dSh2w+gY0JtwZkrKKNGapP?= =?us-ascii?Q?1cZinfRwaJSh3vNYyqo8jJ2+GPFTZZozoXM7BDpuTS40aFaIqXNsnE6i0cXP?= =?us-ascii?Q?r13G/t+a69teEpxv6fnEsgtv12mAIgCHZ/BaAgcQHtZuD3D6+rKQmNv14Lrs?= =?us-ascii?Q?Fmctb3nXBL9LLzp+V+p1XWWipxhsO6a8XPiDfeozO96RhHgZjN9i16sbZTOw?= =?us-ascii?Q?MgGZxjv1igMsjCF+s1zx4t3I57kEv7uCJSJkFHX9NM9GJle0dkWIYG4E3ZmN?= =?us-ascii?Q?h6SuMX2PCc7rdAO1k07466t4FRxUcSQ4WZc64QBwEdQX6MaxkASUli86gzUn?= =?us-ascii?Q?Ubl9TCylRFx3Mras5ZbZnHkTfcIbNiHlND+kV74rL0j9eKSccAxVGff86E1j?= =?us-ascii?Q?Fu+MfICkXAXsAZ5ZXmcvHvfvaw2uVF5k0KAQ89ZkqvRw9PpBjO4ZLxcGRwBt?= =?us-ascii?Q?V1dd5FsEWVIKnhm9CME5idRvkQ4+Re3GxN1kplBYB61wuPukkJ8U7/OcVrNv?= =?us-ascii?Q?Z72TaUnAyCbjjDXHIZeHh5TffbeTAW8pSgi8hXCBqHp76Rp/84H0OpZmLO3d?= =?us-ascii?Q?de4pqN1l6/I++Bk6D34C6CPPwpBBAYeFlFuhZMe/Yc1f+6lHd3Lx406ZCImu?= =?us-ascii?Q?8aa+AjPNpCLyirjSbkR7jAzgq5VxH9blMOYRWlHKH8Gq5P8pKdFHh73QkszW?= =?us-ascii?Q?jN7LY4l4Ntejdz5wPaycOIAR1VLctOsbECo7HgtSxzQTYUY0ulfScvLMDEmb?= =?us-ascii?Q?EEhD+0u/XvVwbDaNaYchUlVLSnhb0uz6T5LbTboe3foWTtmzx/iA7YLkgnR9?= =?us-ascii?Q?lfgKpfqw1M/DAquQQqA7bh541P6DlUMXpCXtTYw+GlW0BgwF3V3GppuRaMeB?= =?us-ascii?Q?mOT6jOeGouQPVKjWL98t8eOOyGh/lZhdxbEonpNBVRrIjUEL+KKsw3XBlLO9?= =?us-ascii?Q?30nmfOkK37UiYdaexz5zQao2I8/abYWJmrrdT6W828ZtQg=3D=3D?= 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: =?us-ascii?Q?eUrLMtOKbXz6rRCI1EBe9aPMWK8/kMa6L1fHTeh6M5MLg06jVGHapYmplGiI?= =?us-ascii?Q?4IuokyBGQz5asvvR7NbWSsat62oWqFkEuvcHXGnZSb+ecrh/mqh9hzcwt7ZM?= =?us-ascii?Q?YCWP7qWksUVWcLblCTeOjG+CF1mmKn9bp+n2tSTXnv4/3ouSo5szbQ+2Dsws?= =?us-ascii?Q?Cm0dlpfUwL76pBW/QJEzF9JPSfqZ6Kvnoivg2pmt0CyBToJvYXuiG/0XPB6F?= =?us-ascii?Q?GPxxIRCVlW9C4oMKwMc0u2Ez7jM3c6bjcDpPEJ1pEfeLtSy+JIr8MUfG3Mii?= =?us-ascii?Q?6iXMcGhZnMw0aZhcmqaTckH9xehbLXp9ctIwX+VsaGDEjI+oJdMXET3yUF9r?= =?us-ascii?Q?0lFB/NegcjAIKRrsjwPI3JL+bEzwLfjBNKkFtieHCDQbMc9K+gU0Vuyr+zVw?= =?us-ascii?Q?t4tBk+mRhoHCT+sxBPGyslG2Umfh9DLIGZuJ7LNXbnEfIb3h4yO9z8FItUSp?= =?us-ascii?Q?9q1vvHdu3Px/IJXI3REttxwIqchN6vqAcISDuap6Uw5+9DMpfXGpB6hiK9r5?= =?us-ascii?Q?3yNbplcm/E2XpQQlUZ0qgrLLxmwQpNGe8qRt3QFH/27TyEgOTTleKTkapIFy?= =?us-ascii?Q?DXRASyhTWb1z3GMBTjRA/PL2BndkfoV++dCMM6pKUv/qAjRtvrSTjN7vQYHt?= =?us-ascii?Q?avWp35Ozc0EavYyRkEc9UJ33R5E6GOB9UAQC3VzeLpzqRvokrWeViPq6XrLH?= =?us-ascii?Q?JF2nLPHVknoBGjjrM4GfG2aC/mH6PfSXJMj+PKEIJUs5eog05kVjgpRfgUeZ?= =?us-ascii?Q?WZ0u0VruTotkA23LEeqtDg1UweKFUZmX2Kb4XerznIKw9mQo5quj+kxhOUOP?= =?us-ascii?Q?mOuW2uUCZqZlbz1zt3fDhHIddCDUmUuCIFHNWwJeP2CZ5epbEYTeBvA0ibbV?= =?us-ascii?Q?KnQd1E4IewPr46x+8CGEbQTOTgeH15NRGciv3eGhQ+V91DrYuTxfg25A3mXO?= =?us-ascii?Q?azA5sxWsq0WIGaw15DFxaDBT5VIStWs7DpPHjqCmohIne5B9nrCxGHaad2hU?= =?us-ascii?Q?+8kMYYFBMQxBOnYymIGkO2Xhk9cZXGG3XGZy/3k7IVwg+yI0hpGjBHHQCUeg?= =?us-ascii?Q?VHVYCP5oMzYaiacm6y+ZWMYmHt88tr3lTVfG1MvtNqUw2Tcdb3uooOBJE7X+?= =?us-ascii?Q?5FsGc4xr3qnewbnMkTuzH68uo3OADyOo5HCMoUm5a0Oi6IdRvL//ccB/1H2h?= =?us-ascii?Q?rJ+PfpTxh77w+GkzwGXQlaWrKfjW6g8kMoC+y0f73Lu8zPuEb/BRtQdIb9h/?= =?us-ascii?Q?FECxctBngKKjwkUclRolMBzM0UUFbfZZMSXpTGrhA8RU/eO099oOwUIBnXBk?= =?us-ascii?Q?g4HQYhJOGhKTvh6fLN5xgddnTWvDXxRM7AsxAitZflsAH+mu8MNjioMoKgS8?= =?us-ascii?Q?PfEv7hx2JgHI0reKbtEfRhgMn/nN3PGV7qEGGx0TEo9pRwr7+mOFZr8yv8eC?= =?us-ascii?Q?8dGxCAAkbu2NsB7iYIvKPzAYTAF6T6R+EzLRtjIrEShI+NZgofFalHrLvkm+?= =?us-ascii?Q?JgeOBdbI2aIbZI4meBYK7O7WsprFruoYYKuHJed03AUPm1mKmMHb1pD1PnXQ?= =?us-ascii?Q?Efs/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-Debbugs-Envelope-To: 61549 Cc: "alex@bochannek.com" , "larsi@gnus.org" , "monnier@iro.umontreal.ca" , "61549@debbugs.gnu.org" <61549@debbugs.gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" 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) From debbugs-submit-bounces@debbugs.gnu.org Mon Jun 03 22:01:59 2024 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 ) id 1sEJUs-00069i-L5 for submit@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 ) id 1sEJUm-00069S-Mc for 61549@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@bochannek.com From: Alex Bochannek To: Michael Heerdegen Subject: Re: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions In-Reply-To: <871q5da5l6.fsf@web.de> (Michael Heerdegen's message of "Tue, 04 Jun 2024 02:56:21 +0200") References: <83sff41zgm.fsf@gnu.org> <83fsb2xhzp.fsf@gnu.org> <86ed9t5btc.fsf@gnu.org> <87h6eahqcd.fsf@web.de> <864jaamfb3.fsf@gnu.org> <871q5da5l6.fsf@web.de> Date: Mon, 03 Jun 2024 19:01:04 -0700 Message-ID: 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 writes: > Eli Zaretskii 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-Debbugs-Envelope-To: 61549 Cc: Eli Zaretskii , larsi@gnus.org, 61549@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Michael, Eli, Michael Heerdegen writes: > Eli Zaretskii 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. From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 04 10:38:10 2024 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 ) id 1sEVIg-0008Ru-2v for submit@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 ) id 1sEVId-0008RV-Rj for 61549@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 ) 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@gnu.org> From: Eli Zaretskii To: Michael Heerdegen In-Reply-To: <871q5da5l6.fsf@web.de> (message from Michael Heerdegen on Tue, 04 Jun 2024 02:56:21 +0200) Subject: Re: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions References: <83sff41zgm.fsf@gnu.org> <83fsb2xhzp.fsf@gnu.org> <86ed9t5btc.fsf@gnu.org> <87h6eahqcd.fsf@web.de> <864jaamfb3.fsf@gnu.org> <871q5da5l6.fsf@web.de> X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 61549 Cc: 61549@debbugs.gnu.org, larsi@gnus.org, monnier@iro.umontreal.ca, alex@bochannek.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) > From: Michael Heerdegen > Cc: alex@bochannek.com, larsi@gnus.org, monnier@iro.umontreal.ca, > 61549@debbugs.gnu.org > Date: Tue, 04 Jun 2024 02:56:21 +0200 > > Eli Zaretskii 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. From debbugs-submit-bounces@debbugs.gnu.org Wed Jun 05 10:05:39 2024 Received: (at 61549) by debbugs.gnu.org; 5 Jun 2024 14:05:39 +0000 Received: from localhost ([127.0.0.1]:37246 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sErGk-0008PR-JA for submit@debbugs.gnu.org; Wed, 05 Jun 2024 10:05:38 -0400 Received: from mout.web.de ([217.72.192.78]:45489) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sErGh-0008Oz-SW for 61549@debbugs.gnu.org; Wed, 05 Jun 2024 10:05:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1717596315; x=1718201115; i=michael_heerdegen@web.de; bh=iXbYm8syOpXTlYQJ9FGud9tTlq+XPrkcg7Dg22A7IEI=; 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=HE1faSZogqxyz4kBaJein0LfbmU5x3rVq+Q7DfDRrXORviBgpth5513/oJLp0xku 7Mv1m4k4PwEKaAsyyYqnLFCMjCAutxqyi5qKNLc6fU/u/dXAbJPOMijkFo/4l0aa0 Ml1zTAG8/H49qlg1Q2/vBGktg6J3dKBVNwEXrJrOyYwiaKFpqsl4wyMEjcwKsYI1J Wn5FkkYkMiq/ak9QM36m9vfD+shLazpB3CbqYkuEmRbXYCNEFDAaZZAYpd+9M/CpH 9q8VJAdbt81n13cY2oNnr/106enAd0ZvkQHZh+DTAE/lxIm9cAJQUCdLskRfqKWKm 1s+2a1NdFDt7XqakPQ== 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 1MBS6v-1sA8LS0QeN-001nB4; Wed, 05 Jun 2024 15:51:41 +0200 From: Michael Heerdegen To: Alex Bochannek Subject: Re: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions In-Reply-To: (Alex Bochannek's message of "Mon, 03 Jun 2024 19:01:04 -0700") References: <83sff41zgm.fsf@gnu.org> <83fsb2xhzp.fsf@gnu.org> <86ed9t5btc.fsf@gnu.org> <87h6eahqcd.fsf@web.de> <864jaamfb3.fsf@gnu.org> <871q5da5l6.fsf@web.de> Date: Wed, 05 Jun 2024 15:52:27 +0200 Message-ID: <875xunxzs4.fsf@web.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:YMmnbDfgoVwSp7x63IO+j/88I+CXerrzArfapl3GJaWIjRN6IBr v1HbEOsQWS4kWpJ8r8BL5YCGgCeenWQV6dp66koEzCri3VrnV9vh7cKjHo9eVhoBLMrelnQ 0a3tK8dRSDsnGTe0/jWxCt+dUTmhPj0ag+KObahMq/UtAenPtQB7pN/Co7To5VQU2wJPosm H95Baowpa2ljOQ9l8cIeg== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:loM9sm21CwA=;y5SY1zSas+koy7is3dSWJ5r0Ap1 GRwX1GijA/AaCyq1Inlw8Tnd2DsWbae8wjX+9BP5nsPmOj0wwYs1cj4tnoiCqq/2nXwEbHz9t gia59+GS4hv5hxE5IFD6DLx/WIZbW/XIdaCfWZt7mvpS9RUnGxlPmLw6WPD7iEbpkRbpsa8GD pzmWPIqeLPS1aOaBmEJF01ERVki9l32n/YrANnAy06lewxKY1S3QHqN7Vkqtqu2c0DIGtuKu6 ncsQ9MR3PuOk9XsXexU0o2r1HPCULam4uyVJJrvsdxacH716tYEgPjwwnP4KzoOpi8yDe41wz 8zaQlTUumZ9+/6EVDFIpLQqp5j5kh/o/LoFfI1G7SgJnKxGWFrkIOFuS1Eg9RNV6ecy9Tvkhs nWpXhKqZh4PotlZc9iksOehhx20nA8oa/SqR7O4k6A4sSplGqfCYT9+sUBf26z/Yck5JxeqwA cea2sJmknluhViAjdCE3kZIt2gPskdT0nai5ySAkb7iPkS0x+/xP8/eWBFKVgrm/PNljENA74 Y1kNXQNczT6q6HhkFPrBDoRhpg0Dbb4bxhiIKN8EE+96qCyKxyGiUipg3TJuWiPGbKjcqt48W 3XHzxJCBIgwauxP6tx6hTbgurlbnkFk8ynfXuR+viYCocv4PKZYjTwKkUpet0B9MLVFP4x0iW wW9VE3ZsN4s0iv9GMO/Zx5hOFRuHptRiv5eaSf3utk//xb+Lm6kzp+R6tKWm4bHaZ7Z8o6e9e 4dp7rIqr5hcFtRwsv61yHn3zXMQvt6222iAArD2i0GPmb54tg1r+4X28UzY1stR55j/11hKkz mj3EgwtKtTYz+PJuTqLe6rFeRzf83BYigQL+hyLAPC06U= X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 61549 Cc: Eli Zaretskii , larsi@gnus.org, 61549@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Alex Bochannek writes: > The problem I was trying to solve was how to use keyboard macros to > auto-create lists of numbers. I see. Does this cover the most frequent non-trivial use cases well? AFAUI, you allow to change the automatic increment in each macro step, but only once - other cases would get complicated or are not possible. Have you thought about the idea to provide some more explicit way to control the automatic increment of a kmacro counter, like a mathematical formula (a function of one argument, the old counter value, that would calculate the next counter value)? Given your experience with keyboard macros usage, would that be a useful thing? Thanks so far, Michael. From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 07 15:10:19 2024 Received: (at 61549) by debbugs.gnu.org; 7 Jun 2024 19:10:19 +0000 Received: from localhost ([127.0.0.1]:53263 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sFeyg-0008SU-QJ for submit@debbugs.gnu.org; Fri, 07 Jun 2024 15:10:19 -0400 Received: from ns.lapseofthought.com ([50.0.39.240]:23361 helo=mail.lapseofthought.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sFews-0008Mz-DK for 61549@debbugs.gnu.org; Fri, 07 Jun 2024 15:08:27 -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 4VwrLr6YBkz3pdF2; Fri, 7 Jun 2024 12:08:04 -0700 (PDT) Authentication-Results: ORIGINATING; auth=pass smtp.auth=alex smtp.mailfrom=alex@bochannek.com From: Alex Bochannek To: Michael Heerdegen Subject: Re: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions In-Reply-To: <875xunxzs4.fsf@web.de> (Michael Heerdegen's message of "Wed, 05 Jun 2024 15:52:27 +0200") References: <83sff41zgm.fsf@gnu.org> <83fsb2xhzp.fsf@gnu.org> <86ed9t5btc.fsf@gnu.org> <87h6eahqcd.fsf@web.de> <864jaamfb3.fsf@gnu.org> <871q5da5l6.fsf@web.de> <875xunxzs4.fsf@web.de> Date: Fri, 07 Jun 2024 12:07:56 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 61549 Cc: Eli Zaretskii , larsi@gnus.org, 61549@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Michael, Michael Heerdegen writes: > Have you thought about the idea to provide some more explicit way to > control the automatic increment of a kmacro counter, like a mathematical > formula (a function of one argument, the old counter value, that would > calculate the next counter value)? Given your experience with keyboard > macros usage, would that be a useful thing? I think this is a very reasonable idea. I'll have a look at how to generalize this and submit a patch. It will probably take me a little while, but it won't be a year again ;) -- Alex. From debbugs-submit-bounces@debbugs.gnu.org Fri Jun 07 22:19:29 2024 Received: (at 61549) by debbugs.gnu.org; 8 Jun 2024 02:19:29 +0000 Received: from localhost ([127.0.0.1]:56654 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sFlg1-0003Q3-Cz for submit@debbugs.gnu.org; Fri, 07 Jun 2024 22:19:29 -0400 Received: from mail-pg1-f180.google.com ([209.85.215.180]:45320) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sFlfz-0003Ph-RH for 61549@debbugs.gnu.org; Fri, 07 Jun 2024 22:19:28 -0400 Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-6c53a315c6eso2107777a12.3 for <61549@debbugs.gnu.org>; Fri, 07 Jun 2024 19:19:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717813086; x=1718417886; darn=debbugs.gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=lv3hcEQCCvEi2fwNPq0k8kgpw01RLNvatLhPRABWMAs=; b=Kr205cr+C3kW18OCfFuJdg4bGobn98tafGQTmgfNPw3hpRYMBSkQGUuoH/QRPqB4JB gf4eK9Kr+NWtq7q+sVm6GpMVNwKj+sxHLhI2REnsRox/asUp5N7PhTkL36PCDUZGBLpo XbpJ+ge0lYEcVIekPKuYF+6BUaehyoN6RUPUFQEtN3sxEIXr0CiluiVk3tBBLB4fo+QO wyR1wOyeKPSulTiCHQewaqVLvz6S8001l3bDUnBLWLljB/nWtB1FsFKWKZLlstN/U9Rm qNrjS9oahS5q5snr27d4E386GKMqWZAyrDKXdyD3068egjICkm1a25udYRjmIBlrXfRz yGBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717813086; x=1718417886; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=lv3hcEQCCvEi2fwNPq0k8kgpw01RLNvatLhPRABWMAs=; b=pWg8kcerc74SX+iW3pTr6hYY8a3hegznNFmoWyzPPnped4sqaNtb+YfGWxETofbRci 9u4nAIp1cu3ZFOZVsvzHi3vhT1GExmv4d1KfNaIKkjpKyBAJ91irEqEcLKZJXlJkYMMl +7UV/ETCmM30Ch5i12ssGvk62xQZT5rk0KxZ0W+DdGYeKb7SS97/SOzJVeHvplMVVPNX 6FES3t+zajyxAOyYIntoYjKz9IO0V8RdY1qRlJgm0H1u4Rpuca1wlQy3GBPgdk6em5ED GaZcnIgwopaHhwZOaVF20RaocG5b+rBhEgyQwlPJKLkOU/b7h14x5AilAfQ4opD9fG6c 2irw== X-Forwarded-Encrypted: i=1; AJvYcCVJv6fGIX1zt6/UiKaJ/biaImL8cR5Bv8dCTXRvdZGbnRprdm6mSp5stRVlhm+aayHAypI/+6GUX6pRuAr5aNvCNOqo4Vk= X-Gm-Message-State: AOJu0YzpVQlCyl5iGN0wjm0aQ+xy7vXNZGaBGAot5VYb7X6fED1Vu4dq QSa+IIrBO4ZMH1yrey3kgcBXXa7h9gUAczt86W6VVg82KzrJinZ/ X-Google-Smtp-Source: AGHT+IHXjtoEcqtK0nPk/Sp6X7eiVEubr5gN4G11YL/Uz4BCz966lze8X5x94QslTGOgauOw0HpgAQ== X-Received: by 2002:a17:90b:1957:b0:2c1:9e9d:b9b5 with SMTP id 98e67ed59e1d1-2c2bcacb6d6mr4033214a91.15.1717813086254; Fri, 07 Jun 2024 19:18:06 -0700 (PDT) Received: from pebl ([2001:8003:7816:8300:7f15:5962:16a0:6470]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2c28066cfc9sm6200824a91.22.2024.06.07.19.18.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 19:18:05 -0700 (PDT) From: Pranshu To: Michael Heerdegen via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Subject: Re: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions In-Reply-To: <875xunxzs4.fsf@web.de> (Michael Heerdegen via's message of "Wed, 05 Jun 2024 15:52:27 +0200") References: <83sff41zgm.fsf@gnu.org> <83fsb2xhzp.fsf@gnu.org> <86ed9t5btc.fsf@gnu.org> <87h6eahqcd.fsf@web.de> <864jaamfb3.fsf@gnu.org> <871q5da5l6.fsf@web.de> <875xunxzs4.fsf@web.de> Date: Sat, 08 Jun 2024 12:18:00 +1000 Message-ID: <87cyosjhyf.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.2 (/) X-Debbugs-Envelope-To: 61549 Cc: Alex Bochannek , Michael Heerdegen , monnier@iro.umontreal.ca, 61549@debbugs.gnu.org, Eli Zaretskii , larsi@gnus.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.8 (/) Also there are multiple ways to include a seires of numbers, such as 'C-x r N'. iirc calc has a way in which you can copy numbers to a rectangleular region. Apart form numbering lists, I am unable to think of another use for using a formula for the macro counte.r From debbugs-submit-bounces@debbugs.gnu.org Sat Jun 08 09:44:56 2024 Received: (at 61549) by debbugs.gnu.org; 8 Jun 2024 13:44:56 +0000 Received: from localhost ([127.0.0.1]:37925 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sFwNL-00064A-Rm for submit@debbugs.gnu.org; Sat, 08 Jun 2024 09:44:56 -0400 Received: from mout.web.de ([217.72.192.78]:57673) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sFwNG-00063r-O1 for 61549@debbugs.gnu.org; Sat, 08 Jun 2024 09:44:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1717854257; x=1718459057; i=michael_heerdegen@web.de; bh=vUvf0tyfaQUkx7YGQr5ZZZjW6TZRRKVUYYlI0V4FXtI=; 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=ULDF8n5N8yh6w+Yqsq4kSpBBDFM1Nnyu0JgekYSFVd3BFLh4G11VHWr5zpND1ZRP A83f2awruJLxE0FZ3k8Plf3qg+pcuZXPYETZKQI+ExD959uotj6Dwfw8d2INFyUHk 7AOR7mJG7YTGdZbfyXB/oQ26hUQuCU6n4IsZlYH9IBMl0/8jOtG5mCQi6w2S92/el bZg1vb3XDdYOdMYoBdQkRd9gaHjfz/eqL7WHF+1I82P755f1xeFCHQlvPJePfHfZJ YWJ3MpQZ+plio8jLVZa/JqcObaA3EX4Z10toGNPSEZLWfbzQjm/pqRYIVD7fU2k5X jOo2FJfwrSKSFZBZiA== 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 1MtPvg-1sZH2N0cLW-011dCy; Sat, 08 Jun 2024 15:44:17 +0200 From: Michael Heerdegen To: Alex Bochannek Subject: Re: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions In-Reply-To: (Alex Bochannek's message of "Fri, 07 Jun 2024 12:07:56 -0700") References: <83sff41zgm.fsf@gnu.org> <83fsb2xhzp.fsf@gnu.org> <86ed9t5btc.fsf@gnu.org> <87h6eahqcd.fsf@web.de> <864jaamfb3.fsf@gnu.org> <871q5da5l6.fsf@web.de> <875xunxzs4.fsf@web.de> Date: Sat, 08 Jun 2024 15:45:04 +0200 Message-ID: <87ikyjft0f.fsf@web.de> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Provags-ID: V03:K1:UV0AMka+JO+kvpE3nW87PPzMvG+dBAGFvEPg3M1geUwsU/KgiRE LNKyqYkowOFtQS6VksvFcRKhf8lCPoKNLle1o6VP0c0mzp13Lj8OIJWTbmQqE5Q31aYlSEg h3jQXkyVQl8G7FQJvctKAq+5djklWRRFLtdqFhq/wG1qNUWPy2aIUWWkve+3XlbwnSF5h80 Y3sFdJPhUV2KDfEyYcTqA== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:S6Wmub3yP3E=;ZmFVaI2xAfy/U0C+XV4DEZuR+Ne cfxPMP91r8YtTXk8aq1tVsbCq8kj2sZn1k4B/kkOK3pvyGUj+i0O5BHGs7ty5WE/MMQe/OQ3f g3eIAC0mTgzR8V4LyvOZXhxFMA0NghaBb3vAcUV6VcK0dx9O5bJQJSL1ai9yl2LRjdfxuVuym EfCP9pwtNKFyEMJ/8b/bYnlLFJsdWnOXp7gnfM2CsgPyKvbzuBk+h55M90kPLSxUmt1VH3doO r3PiDmijjB29VENMi7FJzlXOz1IHeOeEYkqhsHdylOwzv+vrUNlw1lC3Byl1adTtREQssTpps rFNbXo54tp+bsCHDz1z71V9NS8HOC/+KIO4uxHFhUd4FTk4osTON5unrdi3FFNSQZfgF3laSy v5W3pbK/J+V95xwiG/Wa2HiFmQI6ScSttyyaqur/jvbhklPY1VMpc8mrY2CcjaJu7OM7Te4aE 8F9wwMJ8iG2EucP6RiVmLIC8Ii4MibaDfgqgZGbKrcu61XAPkonHYsuCFcKTVkkkCWjyHwrxJ m/RB8xmUDbs0alo8L/ANJoPd+uNYQKha06Vl0TTxCmuiURLvCXkTtaF3KcNmd2KQNlLppZN19 l+6FCwZS+4Km7jppEuirLXKWgfaLyglw7nS/TnXExAg7mBBH7v/DeTaiFHJGqKxUzPnwavihE 3dr+zK+Ot+bLX7CUFgHSTwpPljSxjzWCpDxTAhdndCbz8Ir2CChhzTRmFxSxcfNA2Ee+AddDw R+kDChRTd8Ehm5ODNPxAxAtgxRnFbFAzGyuhg8dqIuasyUhFSdcrMya+zxHWplnDcSctyy7XD N0kDrr1zsvG8nIIhcwrcxg41HhRhfuUs2sel+hGR3U/B4= X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 61549 Cc: Eli Zaretskii , larsi@gnus.org, 61549@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) Alex Bochannek writes: > I think this is a very reasonable idea. I'll have a look at how to > generalize this and submit a patch. Yes, this is the question. AFAIK, there is currently no way to put an Elisp function into a register. Pranshu writes: > Also there are multiple ways to include a seires of numbers, such as > 'C-x r N'. iirc calc has a way in which you can copy numbers to a > rectangleular region. Apart form numbering lists, I am unable to > think of another use for using a formula for the macro counte.r @Alex: do you see other uses? I think it would probably be easier to generalize C-x r N. Should we maybe just do that? Thx, Michael. From debbugs-submit-bounces@debbugs.gnu.org Tue Jun 11 12:10:45 2024 Received: (at 61549) by debbugs.gnu.org; 11 Jun 2024 16:10:45 +0000 Received: from localhost ([127.0.0.1]:35908 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sH456-0001Hg-T8 for submit@debbugs.gnu.org; Tue, 11 Jun 2024 12:10:45 -0400 Received: from ns.lapseofthought.com ([50.0.39.240]:48390 helo=mail.lapseofthought.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sH455-0001HY-0J for 61549@debbugs.gnu.org; Tue, 11 Jun 2024 12:10:43 -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 4Vytqx4cZnz3pdHP; Mon, 10 Jun 2024 20:06:53 -0700 (PDT) Authentication-Results: ORIGINATING; auth=pass smtp.auth=alex smtp.mailfrom=alex@bochannek.com From: Alex Bochannek To: Michael Heerdegen Subject: Re: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions In-Reply-To: <87ikyjft0f.fsf@web.de> (Michael Heerdegen's message of "Sat, 08 Jun 2024 15:45:04 +0200") References: <83sff41zgm.fsf@gnu.org> <83fsb2xhzp.fsf@gnu.org> <86ed9t5btc.fsf@gnu.org> <87h6eahqcd.fsf@web.de> <864jaamfb3.fsf@gnu.org> <871q5da5l6.fsf@web.de> <875xunxzs4.fsf@web.de> <87ikyjft0f.fsf@web.de> Date: Mon, 10 Jun 2024 20:06:52 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 61549 Cc: Eli Zaretskii , larsi@gnus.org, 61549@debbugs.gnu.org, monnier@iro.umontreal.ca X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Michael, Michael Heerdegen writes: > Alex Bochannek writes: > >> I think this is a very reasonable idea. I'll have a look at how to >> generalize this and submit a patch. > > Yes, this is the question. AFAIK, there is currently no way to put an > Elisp function into a register. This may not work, but I was thinking along the lines of storing the text for a lambda in a string register and then doing something like: (setq kmacro-counter (funcall (read (get-register ?A)) kmacro-counter)) Haven't really tried it and this may be a bad idea for any number of reasons. > Pranshu writes: > >> Also there are multiple ways to include a seires of numbers, such as >> 'C-x r N'. iirc calc has a way in which you can copy numbers to a >> rectangleular region. Apart form numbering lists, I am unable to >> think of another use for using a formula for the macro counte.r > > @Alex: do you see other uses? I use keyboard macros frequently when I am manipulating multiple text buffers to extract or merge data. Basically, anytime it gets slightly too complicated for a quick AWK one-liner. The example of generating a list of numbers came up in an IRC conversation and I wrote about it in a blog post: https://abochannek.github.io/emacs/2023/03/09/emacs-kbdmacros.html (There is a link to a first part in that post that explains the history of keyboard macros in Emacs.) The examples are artificial and caused me to look into different ways to do counter increments. After I implemented the conditional increment, I found myself using it occasionally with keyboard macros to parse irregular text files and collect bits and pieces from multiple buffers that I then numbered in different ways. I certainly don't use it frequently and the conditional quit is more useful. The way I used to do construct lists with macros before is to have a buffer with pre-generated numbers and have the macro kill/yank numbers from there. Generalizing C-x r N may be helpful for that, I tend to just use C-u M-! and then seq or jot, depending on what I need. You may notice a couple of things in my blog post. I am suggesting number registers as an alternative to the macro counter. They work well in most cases except that they don't have a way to change the increment conditionally either. Secondly, I am jealously looking at Calc macros, because what I really want for keyboard macros is programmability with proper loops and conditional branching. I don't honestly know (nor do I know how to find out) how widely keyboard macros in Emacs are used. I quickly record a new macro almost daily and have in the past stored more complicated named macros in my init file for later recall. Because what I use them for is usually one-time work, I have not built up a library of functions for myself. I would guess that my average keyboard macro is maybe between five and twenty commands. -- Alex. From unknown Fri Jun 20 07:14:10 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Wed, 10 Jul 2024 11:24:16 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator