> Here's an example of when I am not sure:
> (message (substitute-command-keys "Press \\[wdired-finish-edit] when
> finished \
> or \\[wdired-abort-changes] to abort changes")))
> Can the above code ever lead to errors?
Yes.
> Either way, isn't it safe to insert a "%s" after message anyways?
The only case where it's not safe is when the existing code already does
%-escaping, in which case adding the "%s" will cause any % sign in the
output string to appear twice. That's extremely rare and I suspect it only
happens in cases where the sole arg to message is a string constant (which
thus contains a double % sign).
> All this almost makes one wonder if it would make sense to provide a
> msg:
> (defun msg (arg)
> (message "%s" arg))
> A lot of times, an author accidentally writes the code with msg in
> mind rather than message. This error is pervasive, especially if you
> look at all the add-on code (not part of emacs). I bet there is aon
> average, at least one bug per file.
In the past I suggested to make (message ARG) automatically behave like
(message "%s" ARG) and AFAIK the only prolem with that was a few rare case
like (message "Compiling list...( 0%%)") and those problems are easy to fix.
Stefan
_______________________________________________
Emacs-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/emacs-devel