[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: (message (format "File %s" file))

From: Stefan Monnier
Subject: Re: (message (format "File %s" file))
Date: Wed, 31 Aug 2005 18:10:27 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

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


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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]