From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#61549: 30.0.50; [PATCH] New keyboard macro counter functions Date: Fri, 17 Feb 2023 10:13:45 +0200 Message-ID: <83sff41zgm.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="6558"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 61549@debbugs.gnu.org To: Alex Bochannek , Stefan Monnier , Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Feb 17 09:14:22 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pSvsr-0001TU-HE for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 17 Feb 2023 09:14:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pSvsb-00030F-EA; Fri, 17 Feb 2023 03:14:05 -0500 Original-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 1pSvsZ-0002zz-0i for bug-gnu-emacs@gnu.org; Fri, 17 Feb 2023 03:14:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pSvsY-0000cQ-OF for bug-gnu-emacs@gnu.org; Fri, 17 Feb 2023 03:14:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pSvsY-0006TX-6E for bug-gnu-emacs@gnu.org; Fri, 17 Feb 2023 03:14:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 17 Feb 2023 08:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61549 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 61549-submit@debbugs.gnu.org id=B61549.167662164024876 (code B ref 61549); Fri, 17 Feb 2023 08:14:02 +0000 Original-Received: (at 61549) by debbugs.gnu.org; 17 Feb 2023 08:14:00 +0000 Original-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 Original-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 Original-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==; Original-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 In-Reply-To: (message from Alex Bochannek on Thu, 16 Feb 2023 00:17:25 -0800) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:255862 Archived-At: > 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.