From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#23425: master branch: `message' wrongly corrupts ' to curly quote. Date: Tue, 3 May 2016 16:27:16 +0000 Message-ID: <20160503162716.GB11330@acm.fritz.box> References: <7e599cf6-18c3-1633-33d5-e9f4eaa8fe6a@cs.ucla.edu> <20160502191031.GB2048@acm.fritz.box> <83a8k7kv87.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1462292948 27555 80.91.229.3 (3 May 2016 16:29:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 3 May 2016 16:29:08 +0000 (UTC) Cc: eggert@cs.ucla.edu, 23425@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue May 03 18:28:56 2016 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 1axdBj-0007Hs-84 for geb-bug-gnu-emacs@m.gmane.org; Tue, 03 May 2016 18:28:43 +0200 Original-Received: from localhost ([::1]:42183 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axdBf-0003oR-H9 for geb-bug-gnu-emacs@m.gmane.org; Tue, 03 May 2016 12:28:39 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:42497) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axdBM-0003N1-BR for bug-gnu-emacs@gnu.org; Tue, 03 May 2016 12:28:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axdB8-000802-44 for bug-gnu-emacs@gnu.org; Tue, 03 May 2016 12:28:14 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:51451) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axdB7-0007wf-VE for bug-gnu-emacs@gnu.org; Tue, 03 May 2016 12:28:06 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1axdB4-0000Aj-J2 for bug-gnu-emacs@gnu.org; Tue, 03 May 2016 12:28:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 03 May 2016 16:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23425 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23425-submit@debbugs.gnu.org id=B23425.1462292841598 (code B ref 23425); Tue, 03 May 2016 16:28:02 +0000 Original-Received: (at 23425) by debbugs.gnu.org; 3 May 2016 16:27:21 +0000 Original-Received: from localhost ([127.0.0.1]:35552 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1axdAO-00009Z-UN for submit@debbugs.gnu.org; Tue, 03 May 2016 12:27:21 -0400 Original-Received: from mail.muc.de ([193.149.48.3]:64813) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1axdAM-00009Q-Ka for 23425@debbugs.gnu.org; Tue, 03 May 2016 12:27:19 -0400 Original-Received: (qmail 35825 invoked by uid 3782); 3 May 2016 16:27:17 -0000 Original-Received: from acm.muc.de (p548A45E2.dip0.t-ipconnect.de [84.138.69.226]) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 03 May 2016 18:27:16 +0200 Original-Received: (qmail 22227 invoked by uid 1000); 3 May 2016 16:27:16 -0000 Content-Disposition: inline In-Reply-To: <83a8k7kv87.fsf@gnu.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:117650 Archived-At: Hello, Eli. On Tue, May 03, 2016 at 06:38:16PM +0300, Eli Zaretskii wrote: > > Date: Mon, 2 May 2016 19:10:31 +0000 > > From: Alan Mackenzie > > Cc: 23425@debbugs.gnu.org > > Hello, Paul. > Hello, Alan. [ .... ] > > On Mon, May 02, 2016 at 10:53:59AM -0700, Paul Eggert wrote: > > > (message "%s" M) is the usual way to output a message M without > > > formatting it, and something like this is needed anyway if M might > > > contain %. > > That is the case for a string that might contain percent characters. It > > is not the case for a string known to be without percents. > It is now. In general, the first argument of 'message' is not copied > to output verbatim, so the advice to use "%s" is a sound one. > Especially when you are going to display a string that is produced > dynamically, and so you don't have complete control on the result. > It's simply dangerous. We just got one more use case in support of > that advice. > > There was nothing wrong with `c-replay-parse-state-state'; it used > > `message' as documented. Your change implies that your workaround for > > `message''s problems is instead to write something like: > > (message "%s" (format "......." .....)) > > , which is ridiculous. > I don't see it as ridiculous. You'd have similar problems (and use > the same solution) if the string produced by 'format' included % > characters, right? I suppose so. Have you got anything agains me putting that suggestion into etc/NEWS, in the entry for `message'? > > In a format string containing single quotes, curved quotes `like > > this' and grave quotes `like this' work better than straight > > quotes 'like this', as `message' typically formats every straight > > quote as a curved closing quote. > > [...] > > Why is there no clear definition of what is meant by the confusing terms > > "single quotes", "grave quotes", and "straight quotes"? > Not sure what you mean: AFAICT, the definition is right there in the > text you cited. Only in the form of characters I can't distinguish on my terminal, and couldn't even if they were distinct due to my failing eyesight ;-). And not in the form I would need to be able to program with them, such as their ASCII/UTF-8 codes. > > Why is there no mention of `text-quoting-style' on this page? > Because we don't want to advertise it too much. It is supposed to be > a kind of "fire escape", not something users must routinely do. If > that assumption is wrong, then having this prominently mentioned in > the manual will be the least of our troubles. If I need to output source code using `message', I will need to bind `text-quoting-style' to a sensible value, won't I? That is an argument for full documentation of it. And why is it something that users shouldn't routinely do? Surely it should be a configuration variable. Some people, like me, don't like being lied to by a computer program. > > How do I configure my Emacs so that `message' behaves properly? > I urge you not to do that. Because if you do, problems like this one > will slip unnoticed, instead of being fixed in the code. I'd like it to be fixed in the code. :-) > > Properly, for me, means that it handles percent escape sequences, AND > > OTHERWISE LEAVES THE STRING UNCHANGED. Why is this information not in > > the manual and the doc string? > AFAICT, 'grave' is that value. And it is documented. No, `grave' doesn't work. This changes curly quotes to ASCII quotes, i.e. it distorts the input and loses information. The value wanted, let's call it `leave', would suppress all substitution of quotes. > > > and the quoting change in Emacs 25 is documented in etc/NEWS, so it is > > > not a bug per se. > > Why is it not in the section "incompatible Lisp changes"? > Because it isn't. If this is an incompatible change, then every new > features that changes behavior is also an incompatible change. No. This particular change causes previously working lisp code (such as my function from yesterday) to stop working. > > How do I restore the old behaviour of `message'? > By setting text-quoting-style. But again, please don't. I want my Emacs to deliver messages to me as they were intended by the people who wrote them. I have a visceral disgust of and hate for this distortion of strings caused by this translation of quotes. I'm sure I'm not the only person who feels like this (and indeed, there were snide/sarcastic remarks on this list yesterday in my support). I want to configure my Emacs to work right for me. I don't understand why this isn't intended to be configurable. > > Can we please fix this before Emacs 25.1 gets released? > What fix would you like to see? I'm not sure I understand. I want there to be an additional value `leave' for `text-quoting-style' which would suppress all substitution of quotes. Something like this: diff --git a/lisp/help-fns.el b/lisp/help-fns.el index 6e8a108..b5a2c84 100644 --- a/lisp/help-fns.el +++ b/lisp/help-fns.el @@ -626,7 +626,7 @@ describe-function-1 ;; Avoid asking the user annoying questions if she decides ;; to save the help buffer, when her locale's codeset ;; isn't UTF-8. - (unless (memq text-quoting-style '(straight grave)) + (unless (memq text-quoting-style '(leave straight grave)) (set-buffer-file-coding-system 'utf-8)))))))) ;; Add defaults to `help-fns-describe-function-functions'. diff --git a/src/doc.c b/src/doc.c index 7cdb0d0..b858e64 100644 --- a/src/doc.c +++ b/src/doc.c @@ -704,6 +704,8 @@ text_quoting_style (void) ? default_to_grave_quoting_style () : EQ (Vtext_quoting_style, Qgrave)) return GRAVE_QUOTING_STYLE; + else if (EQ (Vtext_quoting_style, Qleave)) + return LEAVE_QUOTING_STYLE; else if (EQ (Vtext_quoting_style, Qstraight)) return STRAIGHT_QUOTING_STYLE; else @@ -988,7 +990,8 @@ Otherwise, return a new string. */) int ch = STRING_CHAR_AND_LENGTH (strp, len); if ((ch == LEFT_SINGLE_QUOTATION_MARK || ch == RIGHT_SINGLE_QUOTATION_MARK) - && quoting_style != CURVE_QUOTING_STYLE) + && quoting_style != CURVE_QUOTING_STYLE + && quoting_style != LEAVE_QUOTING_STYLE) { *bufp++ = ((ch == LEFT_SINGLE_QUOTATION_MARK && quoting_style == GRAVE_QUOTING_STYLE) @@ -1033,6 +1036,7 @@ void syms_of_doc (void) { DEFSYM (Qfunction_documentation, "function-documentation"); + DEFSYM (Qleave, "leave"); DEFSYM (Qgrave, "grave"); DEFSYM (Qstraight, "straight"); @@ -1046,7 +1050,11 @@ syms_of_doc (void) DEFVAR_LISP ("text-quoting-style", Vtext_quoting_style, doc: /* Style to use for single quotes in help and messages. -Its value should be a symbol. +Its value should be a symbol. It works by substituting certain single +quotes for certain other single quotes. This is done in help output and +`message' output. It is not done in `format'. + +`leave' means do not do any substitutions. `curve' means quote with curved single quotes \\=‘like this\\=’. `straight' means quote with straight apostrophes \\='like this\\='. `grave' means quote with grave accent and apostrophe \\=`like this\\='. diff --git a/src/editfns.c b/src/editfns.c index f0ce4e7..415d3c3 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -3923,6 +3923,8 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) multibyte = true; int quoting_style = message ? text_quoting_style () : -1; + if (quoting_style == LEAVE_QUOTING_STYLE) + quoting_style = -1; /* If we start out planning a unibyte result, then discover it has to be multibyte, we jump back to retry. */ diff --git a/src/lisp.h b/src/lisp.h index 6a98adb..6a53671 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4183,6 +4183,9 @@ extern void syms_of_callproc (void); /* Defined in doc.c. */ enum text_quoting_style { + /* Leave quotes unchanged. */ + LEAVE_QUOTING_STYLE, + /* Use curved single quotes ‘like this’. */ CURVE_QUOTING_STYLE, > Thanks. -- Alan Mackenzie (Nuremberg, Germany).