[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
(message (format "File %s" file))
From: |
D Goel |
Subject: |
(message (format "File %s" file)) |
Date: |
Wed, 31 Aug 2005 16:33:26 -0400 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
A *lot* of source code contains easy-to-miss bugs like this:
(message (format "File: %s" file))
which will lead to erers like these:
Debugger entered--Lisp error: (error "Not enough arguments for format string")
if the filename contains %.
I plan to go through the entire source code, and only in cases I am
sure, fix these bugs (which mostly involves adding a "%s% after
`message', or getting rid of the unnecessary format call following
(message).
(I will be spotting these bugs with the aid of a regexp search tool).
I have committ access, but this is the first time I am planning to
make any real changes (which happen te be large-scale too), so I
thought I should ask for permission as well as any suggestions before
doing so. For each fix, I would add a proper changlog entry saying
something like: message format spec fix.
Here are a few examples:
iswitchb:
(message (format "no buffer matching `%s'" buf)))))
printing.el:
(message (error-message-string data)))))
flyspell:
(message (format "duplicate `%s'" word)))
gud:
(message (format "Error parsing file %s." file))
I will leave any code alone unless I am absolutely sure of what I am
doing.
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?
====================================================
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.
Sincerely,
DG http://gnufans.net/
--
- (message (format "File %s" file)),
D Goel <=