From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: (message (format "File %s" file)) Date: Wed, 31 Aug 2005 18:10:27 -0400 Message-ID: References: <873bop978p.fsf@gnufans.net> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1125527702 1554 80.91.229.2 (31 Aug 2005 22:35:02 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 31 Aug 2005 22:35:02 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 01 00:34:53 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1EAb3S-0001lV-KB for ged-emacs-devel@m.gmane.org; Thu, 01 Sep 2005 00:27:38 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EAb7f-0001PS-BI for ged-emacs-devel@m.gmane.org; Wed, 31 Aug 2005 18:31:59 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1EAaxk-00065z-HL for emacs-devel@gnu.org; Wed, 31 Aug 2005 18:21:45 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1EAaxW-0005yB-Jk for emacs-devel@gnu.org; Wed, 31 Aug 2005 18:21:31 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1EAaxW-0005uc-CO for emacs-devel@gnu.org; Wed, 31 Aug 2005 18:21:30 -0400 Original-Received: from [132.204.24.67] (helo=mercure.iro.umontreal.ca) by monty-python.gnu.org with esmtp (Exim 4.34) id 1EAape-0005V8-U0 for emacs-devel@gnu.org; Wed, 31 Aug 2005 18:13:23 -0400 Original-Received: from hidalgo.iro.umontreal.ca (hidalgo.iro.umontreal.ca [132.204.27.50]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id 48B692CF54C; Wed, 31 Aug 2005 18:10:34 -0400 (EDT) Original-Received: from asado.iro.umontreal.ca (asado.iro.umontreal.ca [132.204.24.84]) by hidalgo.iro.umontreal.ca (Postfix) with ESMTP id AC9E84AC00B; Wed, 31 Aug 2005 18:10:27 -0400 (EDT) Original-Received: by asado.iro.umontreal.ca (Postfix, from userid 20848) id 6F181E6C1E; Wed, 31 Aug 2005 18:10:27 -0400 (EDT) Original-To: "D Goel" In-Reply-To: <873bop978p.fsf@gnufans.net> (D. Goel's message of "Wed, 31 Aug 2005 16:33:26 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=-4.844, requis 5, autolearn=not spam, AWL 0.06, BAYES_00 -4.90) X-MailScanner-From: monnier@iro.umontreal.ca 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: news.gmane.org gmane.emacs.devel:42537 Archived-At: > 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