unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* kmacro.el
@ 2004-11-30  4:00 Luc Teirlinck
  2004-11-30  9:36 ` kmacro.el Kim F. Storm
  2004-12-01  2:57 ` kmacro.el Richard Stallman
  0 siblings, 2 replies; 4+ messages in thread
From: Luc Teirlinck @ 2004-11-30  4:00 UTC (permalink / raw)


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: kmacro.el
  2004-11-30  4:00 kmacro.el Luc Teirlinck
@ 2004-11-30  9:36 ` Kim F. Storm
  2004-12-01  4:39   ` kmacro.el Luc Teirlinck
  2004-12-01  2:57 ` kmacro.el Richard Stallman
  1 sibling, 1 reply; 4+ messages in thread
From: Kim F. Storm @ 2004-11-30  9:36 UTC (permalink / raw)
  Cc: emacs-devel

Luc Teirlinck <teirllm@dms.auburn.edu> writes:

> 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.

Indeed -- thanks for working on this.

>
> 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.

I don't recall why I made that change -- maybe to debug something.

>
> 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.

Can't we just eliminate the call to format, i.e. instead of

(message "%s" (format "%s%s..." ...))

use

(message "%s%s..." ...)

> Once it would be determined that these changes, as well as the changes
> I am going to propose to man/kmacro.texi are OK, 

They look OK.  Please install.

>                                                  I also intend to
> propose several changes to docstrings that are not very clear, or even
> misleading.

Please do.

-- 
Kim F. Storm <storm@cua.dk> http://www.cua.dk

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: kmacro.el
  2004-11-30  4:00 kmacro.el Luc Teirlinck
  2004-11-30  9:36 ` kmacro.el Kim F. Storm
@ 2004-12-01  2:57 ` Richard Stallman
  1 sibling, 0 replies; 4+ messages in thread
From: Richard Stallman @ 2004-12-01  2:57 UTC (permalink / raw)
  Cc: emacs-devel

    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.

This seems clean to me.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: kmacro.el
  2004-11-30  9:36 ` kmacro.el Kim F. Storm
@ 2004-12-01  4:39   ` Luc Teirlinck
  0 siblings, 0 replies; 4+ messages in thread
From: Luc Teirlinck @ 2004-12-01  4:39 UTC (permalink / raw)
  Cc: emacs-devel

Kim Storm wrote:

   >
   > 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.

   Can't we just eliminate the call to format, i.e. instead of

   (message "%s" (format "%s%s..." ...))

   use

   (message "%s%s..." ...)

Indeed.  I failed to notice this.

Sincerely,

Luc.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-12-01  4:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-30  4:00 kmacro.el Luc Teirlinck
2004-11-30  9:36 ` kmacro.el Kim F. Storm
2004-12-01  4:39   ` kmacro.el Luc Teirlinck
2004-12-01  2:57 ` kmacro.el Richard Stallman

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).