From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Luc Teirlinck Newsgroups: gmane.emacs.devel Subject: kmacro.el Date: Mon, 29 Nov 2004 22:00:31 -0600 (CST) Message-ID: <200411300400.iAU40Vn26724@raven.dms.auburn.edu> NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1101787362 19409 80.91.229.6 (30 Nov 2004 04:02:42 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 30 Nov 2004 04:02:42 +0000 (UTC) Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Nov 30 05:02:37 2004 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1CYzDp-0006IZ-00 for ; Tue, 30 Nov 2004 05:02:37 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CYzNF-0004fu-7W for ged-emacs-devel@m.gmane.org; Mon, 29 Nov 2004 23:12:21 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1CYzMs-0004du-VF for emacs-devel@gnu.org; Mon, 29 Nov 2004 23:11:59 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1CYzMr-0004dK-PV for emacs-devel@gnu.org; Mon, 29 Nov 2004 23:11:58 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1CYzMr-0004dH-MO for emacs-devel@gnu.org; Mon, 29 Nov 2004 23:11:57 -0500 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1CYzDB-0005BW-9P for emacs-devel@gnu.org; Mon, 29 Nov 2004 23:01:57 -0500 Original-Received: from raven.dms.auburn.edu (raven.dms.auburn.edu [131.204.53.29]) by manatee.dms.auburn.edu (8.12.10/8.12.10) with ESMTP id iAU41uFu020818 for ; Mon, 29 Nov 2004 22:01:56 -0600 (CST) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.7p1+Sun/8.11.7) id iAU40Vn26724; Mon, 29 Nov 2004 22:00:31 -0600 (CST) X-Authentication-Warning: raven.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: emacs-devel@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:30509 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:30509 I mentioned a while ago that I had read /man/kmacro.texi, but that there where still problems left, in particular that the section on the macro counter was hard to understand. The reason for that was that there were several bugs and inconsistencies with the counter, most of which (or to say something safer, most of which I know about) have been fixed in the meantime. I believe inconsistencies with the counter _format_ remain. The following patch takes care of those. I believe that it is not very intuitive that if you change the format _during definition_ of a macro that this affects all subsequent macros as well. I also believe that if you change the format before defining a keyboard macro and then notice that you still want to execute another macro before starting the definition, then that should not change the format of that other macro. The new behavior is simple, with no surprises: Changing the format _never_ affects macros defined prior to the change. (As already said there currently are situations where existing macros can be affected.) Changing the format when no kmacro is being defined or executed affects all macros defined from then on. (Until the format is changed again.) Changing the format during macro definition changes the format of the macro being defined from that stage on, during definition and execution, but (unlike at present) does not affect subsequent macros still to be defined. I have the impression that the above described behavior was actually always the _intended_ behavior and that the fact that the actual behavior is different is an inadvertent bug, rather than intentional. The patch also removes the "(printf format)" from the `C-x C-k C-f' prompt. This is misleading. No C style printf format is used but an Elisp `format' format. Better no hint than a false hint. This is a specialized function intended for more knowledgeable users anyway. The other two small changes seem obvious: (and nil ... makes no sense. The other `and' arguments are ignored. In the call to `message' the extra "%s" is necessary, because the user could have used %s or %o sequences in the macro text, that are intended literally. That is, for instance `C-x C-k C-v' will print: let*: Not enough arguments for format string when invoked after: C-x ( %s%s RET C-x ) Something similar actually happened to me in practice (that is how I noticed), so it is not a far fetched possibility at all. Once it would be determined that these changes, as well as the changes I am going to propose to man/kmacro.texi are OK, I also intend to propose several changes to docstrings that are not very clear, or even misleading. ===File ~/kmacro.el-diff==================================== *** kmacro.el 01 Nov 2004 17:50:00 -0600 1.24 --- kmacro.el 25 Nov 2004 20:43:20 -0600 *************** *** 237,242 **** --- 237,244 ---- (defvar kmacro-counter 0 "*Current keyboard macro counter.") + (defvar kmacro-default-counter-format "%d") + (defvar kmacro-counter-format "%d" "*Current keyboard macro counter format.") *************** *** 268,279 **** (defun kmacro-set-format (format) "Set macro counter FORMAT." ! (interactive "sMacro Counter Format (printf format): ") (setq kmacro-counter-format (if (equal format "") "%d" format)) ;; redefine initial macro counter if we are not executing a macro. (if (not (or defining-kbd-macro executing-kbd-macro)) ! (setq kmacro-counter-format-start kmacro-counter-format))) (defun kmacro-display-counter (&optional value) --- 270,281 ---- (defun kmacro-set-format (format) "Set macro counter FORMAT." ! (interactive "sMacro Counter Format: ") (setq kmacro-counter-format (if (equal format "") "%d" format)) ;; redefine initial macro counter if we are not executing a macro. (if (not (or defining-kbd-macro executing-kbd-macro)) ! (setq kmacro-default-counter-format kmacro-counter-format))) (defun kmacro-display-counter (&optional value) *************** *** 404,411 **** (let* ((x 60) (m (format-kbd-macro macro)) (l (length m)) ! (z (and nil trunc (> l x)))) ! (message (format "%s%s: %s%s" (or descr "Macro") (if (= kmacro-counter 0) "" (format " [%s]" (format kmacro-counter-format-start kmacro-counter))) --- 406,414 ---- (let* ((x 60) (m (format-kbd-macro macro)) (l (length m)) ! (z (and trunc (> l x)))) ! (message "%s" ! (format "%s%s: %s%s" (or descr "Macro") (if (= kmacro-counter 0) "" (format " [%s]" (format kmacro-counter-format-start kmacro-counter))) *************** *** 588,594 **** kmacro-initial-counter-value nil kmacro-counter-value-start kmacro-counter kmacro-last-counter kmacro-counter ! kmacro-counter-format-start kmacro-counter-format)) (start-kbd-macro append (and append --- 591,598 ---- kmacro-initial-counter-value nil kmacro-counter-value-start kmacro-counter kmacro-last-counter kmacro-counter ! kmacro-counter-format kmacro-default-counter-format ! kmacro-counter-format-start kmacro-default-counter-format)) (start-kbd-macro append (and append ============================================================ LocalWords: diff