From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#20707: [PROPOSED PATCH] Use curved quoting in C-generated errors Date: Thu, 04 Jun 2015 08:43:50 -0700 Organization: UCLA Computer Science Department Message-ID: <55707236.6060605@cs.ucla.edu> References: <20150601104935.19764.qmail@mail.muc.de> <556C81C4.3010107@cs.ucla.edu> <20150601171723.GB16298@acm.fritz.box> <556CA97C.8070807@cs.ucla.edu> <20150602115600.GA3468@acm.fritz.box> <556DCE36.9070505@cs.ucla.edu> <20150602170724.GA2567@acm.fritz.box> <20150602204423.GA2619@acm.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1433432737 22690 80.91.229.3 (4 Jun 2015 15:45:37 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 4 Jun 2015 15:45:37 +0000 (UTC) Cc: 20707@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jun 04 17:45:27 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Z0XKW-0005Gn-Ie for geb-bug-gnu-emacs@m.gmane.org; Thu, 04 Jun 2015 17:45:16 +0200 Original-Received: from localhost ([::1]:42976 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0XKV-0000xu-Kd for geb-bug-gnu-emacs@m.gmane.org; Thu, 04 Jun 2015 11:45:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45085) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0XKP-0000sg-J0 for bug-gnu-emacs@gnu.org; Thu, 04 Jun 2015 11:45:10 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z0XKJ-0006WS-Rv for bug-gnu-emacs@gnu.org; Thu, 04 Jun 2015 11:45:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:58961) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z0XKJ-0006Vt-Oy for bug-gnu-emacs@gnu.org; Thu, 04 Jun 2015 11:45:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Z0XKJ-0001a8-6k for bug-gnu-emacs@gnu.org; Thu, 04 Jun 2015 11:45:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 04 Jun 2015 15:45:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 20707 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 20707-submit@debbugs.gnu.org id=B20707.14334326445992 (code B ref 20707); Thu, 04 Jun 2015 15:45:03 +0000 Original-Received: (at 20707) by debbugs.gnu.org; 4 Jun 2015 15:44:04 +0000 Original-Received: from localhost ([127.0.0.1]:40703 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z0XJJ-0001YJ-Aj for submit@debbugs.gnu.org; Thu, 04 Jun 2015 11:44:03 -0400 Original-Received: from zimbra.cs.ucla.edu ([131.179.128.68]:40526) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Z0XJG-0001Xt-E2 for 20707@debbugs.gnu.org; Thu, 04 Jun 2015 11:43:59 -0400 Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 006C91606C2; Thu, 4 Jun 2015 08:43:51 -0700 (PDT) Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id KiJ9Jz35Bxhw; Thu, 4 Jun 2015 08:43:51 -0700 (PDT) Original-Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 3BB3D1606C1; Thu, 4 Jun 2015 08:43:51 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Original-Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 0z4zC6JYuw5x; Thu, 4 Jun 2015 08:43:51 -0700 (PDT) Original-Received: from [192.168.1.9] (pool-100-32-155-148.lsanca.fios.verizon.net [100.32.155.148]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 1D3051606C0; Thu, 4 Jun 2015 08:43:51 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 In-Reply-To: <20150602204423.GA2619@acm.fritz.box> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:103568 Archived-At: Alan Mackenzie wrote: > a typical use of Q would look like this: > > error ("Buffer name " Q(%s) " is in use", SDATA (name)); I'm afraid that's not sufficient, as sometimes we have code like this: insert_string ("\nUses keymap `"); with unbalanced quotes. We can fix this by using another macro, uLSQM in= the=20 originally proposed patch: insert_string ("\nUses keymap "uLSQM); though this is starting to get ugly. The more serious problem, though is that neither approach will work well = in the=20 Elisp code, which is where the vast majority of these quotes live. It wo= uld be=20 quite painful to change this: (format "Parsing `%s': expected %s `%s', got `%s'." a b c d) to this: (format (concat "Parsing " (q "%s") ": expected %s " (q "%s") ", got " (q "%s") ".") a b c) I considered changing 'format' so that it automatically curves quotes in = the=20 format string. But that would mishandle common cases like this: (format "\\`%s" path-separator) where 'format' is being used to compose a regular expression containing '= \`'. More reasonable would be to add a new function, 'format-message', that be= haves=20 like 'format' except it also curves quotes, and to change functions like=20 'message' and 'error' to use 'format-message' instead of plain 'format'. = But=20 even here we have lots of examples like this: (y-or-n-p (format "File `%s' exists; overwrite? " filename)) where we'd have to change 'format' to 'format-message'. We could go the GCC route and add a new format flag 'q', so that the abov= e=20 examples could be written like this: (format "Parsing %qs: expected %s %qs, got %qs." a b c d) (y-or-n-p (format "File %qs exists; overwrite? " filename)) This approach would make sense if 8-bit environments were still common, a= s they=20 were when GCC added the 'q' flag to its message formatter. However, nowa= days=20 8-bit environments are obsolescent (sorry) and so this approach seems lik= e=20 overkill now. If we are bothering to go through code to fix quotes, it's= better=20 to change the above examples to: (format "Parsing =E2=80=98%s=E2=80=99: expected %s =E2=80=98%s=E2=80= =99, got =E2=80=98%s=E2=80=99." a b c d) (y-or-n-p (format "File =E2=80=98%s=E2=80=99 exists; overwrite? " fi= lename)) for two reasons. First, unlike %qs the resulting code will work on older= Emacs=20 implementations and thus will make the code more backward-compatible. Se= cond,=20 it's easier to read and maintain quote marks that you can see.