unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Alan Mackenzie <acm@muc.de>, Eli Zaretskii <eliz@gnu.org>
Cc: 23425@debbugs.gnu.org
Subject: bug#23425: master branch: `message' wrongly corrupts ' to curly quote.
Date: Wed, 4 May 2016 16:49:12 -0700	[thread overview]
Message-ID: <b6310cb1-184c-8643-cced-1c25a7c13d5a@cs.ucla.edu> (raw)
In-Reply-To: <4019c1e5-36b4-745f-b299-16b074bff81e@cs.ucla.edu>

[-- Attachment #1: Type: text/plain, Size: 511 bytes --]

On 05/04/2016 11:39 AM, Paul Eggert wrote:
>
> I plan to look into the further change you proposed, with an eye 
> toward installing something like it (but I hope simpler)

Attached is a proposed patch to master to do this. It disables 
translation from curved quotes, which means that quote translation now 
affects only ` and ', and it documents that the text-quoting-style 
'grave' therefore suppresses all quote translation. This shortens the 
Emacs source code by forty lines or so, which is a good sign.


[-- Attachment #2: 0001-text-quoting-style-now-affects-only-and.txt --]
[-- Type: text/plain, Size: 9662 bytes --]

From 43c28fe338ec99f7f36108b7a2fab0ecd6a284c9 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Wed, 4 May 2016 16:44:37 -0700
Subject: [PATCH] 'text-quoting-style' now affects only ` and '

Change 'text-quoting-style' so that it no longer affects
formatting of curved quotes in format arguments to functions like
'message'.  In particular, when this variable's value is 'grave',
all quotes in formats are output as-is.
* doc/lispref/help.texi (Keys in Documentation):
* doc/lispref/strings.texi (Formatting Strings):
* doc/lispref/tips.texi (Documentation Tips):
* etc/NEWS:
* src/doc.c (syms_of_doc): Document this.
* lisp/help-fns.el (describe-function-1):
* src/doc.c (text_quoting_style, Fsubstitute_command_keys)
(syms_of_doc):
* src/editfns.c (styled_format): Omit now-unnecessary code.
* src/lisp.h (LEAVE_QUOTING_STYLE): Remove.
---
 doc/lispref/help.texi    |  9 ++++-----
 doc/lispref/strings.texi |  5 ++---
 doc/lispref/tips.texi    |  3 +--
 etc/NEWS                 |  6 ++++++
 lisp/help-fns.el         |  2 +-
 src/doc.c                | 41 +++++++++++------------------------------
 src/editfns.c            | 22 ----------------------
 src/lisp.h               |  3 ---
 8 files changed, 25 insertions(+), 66 deletions(-)

diff --git a/doc/lispref/help.texi b/doc/lispref/help.texi
index 58a11f2..381c27f 100644
--- a/doc/lispref/help.texi
+++ b/doc/lispref/help.texi
@@ -332,13 +332,11 @@ Keys in Documentation
 specifies @var{mapvar}'s value as the keymap for any following
 @samp{\[@var{command}]} sequences in this documentation string.
 
-@item ‘
 @itemx `
-(left single quotation mark and grave accent) both stand for a left quote.
+(grave accent) stands for a left quote.
 
-@item ’
 @itemx '
-(right single quotation mark and apostrophe) both stand for a right quote.
+(apostrophe) stands for a right quote.
 
 @item \=
 quotes the following character and is discarded; thus, @samp{\=`} puts
@@ -357,7 +355,8 @@ Keys in Documentation
 If the variable's value is @code{curve}, the style is
 @t{‘like this’} with curved single quotes.  If the value is
 @code{straight}, the style is @t{'like this'} with straight
-apostrophes.  If the value is @code{grave}, the style is @t{`like
+apostrophes.  If the value is @code{grave},
+quotes are not translated and the style is @t{`like
 this'} with grave accent and apostrophe, the standard style
 before Emacs version 25.  The default value @code{nil}
 acts like @code{curve} if curved single quotes are displayable, and
diff --git a/doc/lispref/strings.texi b/doc/lispref/strings.texi
index ce629aa..0e5f5f1 100644
--- a/doc/lispref/strings.texi
+++ b/doc/lispref/strings.texi
@@ -840,9 +840,8 @@ Formatting Strings
 @cindex curved quotes
 @cindex curly quotes
 This function acts like @code{format}, except it also converts any
-curved single quotes in @var{string} as per the value of
-@code{text-quoting-style}, and treats grave accent (@t{`}) and
-apostrophe (@t{'}) as if they were curved single quotes.  @xref{Keys
+grave accents (@t{`}) and apostrophes (@t{'}) in @var{string} as per the
+value of @code{text-quoting-style}.  @xref{Keys
 in Documentation}.
 @end defun
 
diff --git a/doc/lispref/tips.texi b/doc/lispref/tips.texi
index d12de7a..a8589df 100644
--- a/doc/lispref/tips.texi
+++ b/doc/lispref/tips.texi
@@ -679,8 +679,7 @@ Documentation Tips
 @t{'}: @t{`like-this'} rather than @t{‘like-this’}.  This
 older convention was designed for now-obsolete displays in which grave
 accent and apostrophe were mirror images.
-
-Documentation using either convention is converted to the user's
+Documentation using this convention is converted to the user's
 preferred format when it is copied into a help buffer.  @xref{Keys in
 Documentation}.
 
diff --git a/etc/NEWS b/etc/NEWS
index 21602ff..65bd44f 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -353,6 +353,12 @@ mode bindings: 'C-c @ C-a', 'C-c @ C-t', 'C-c @ C-d', and 'C-c @ C-e.'
 before running.  This is controlled by the 'grep-save-buffers'
 variable.
 
++++
+** The variable 'text-quoting-style' no longer affects the treatment
+of curved quotes in format arguments to functions like 'message' and
+'format-message'.  In particular, when this variable's value is
+'grave', all quotes in formats are output as-is.
+
 \f
 * Lisp Changes in Emacs 25.2
 
diff --git a/lisp/help-fns.el b/lisp/help-fns.el
index d1c8b2d..040152a 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 '(leave straight grave))
+            (unless (memq text-quoting-style '(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 5326433..017dd17 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -704,8 +704,6 @@ 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
@@ -982,29 +980,12 @@ Otherwise, return a new string.  */)
 	  nchars++;
 	  changed = true;
 	}
-      else if (! multibyte)
-	*bufp++ = *strp++, nchars++;
       else
 	{
-	  int len;
-	  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 != LEAVE_QUOTING_STYLE)
-	    {
-	      *bufp++ = ((ch == LEFT_SINGLE_QUOTATION_MARK
-			  && quoting_style == GRAVE_QUOTING_STYLE)
-			 ? '`' : '\'');
-	      strp += len;
-	      changed = true;
-	    }
-	  else
-	    {
-	      do
-		*bufp++ = *strp++;
-	      while (--len != 0);
-	    }
+	  *bufp++ = *strp++;
+	  if (multibyte)
+	    while (! CHAR_HEAD_P (*strp))
+	      *bufp++ = *strp++;
 	  nchars++;
 	}
     }
@@ -1036,7 +1017,6 @@ void
 syms_of_doc (void)
 {
   DEFSYM (Qfunction_documentation, "function-documentation");
-  DEFSYM (Qleave, "leave");
   DEFSYM (Qgrave, "grave");
   DEFSYM (Qstraight, "straight");
 
@@ -1051,15 +1031,16 @@ 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.  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'.
+quotes for grave accent and apostrophe.  This is done in help output
+and in functions like `message' and `format-message'.  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\\='.
-The default value nil acts like `curve' if curved single quotes are
-displayable, and like `grave' otherwise.  */);
+`grave' means quote with grave accent and apostrophe \\=`like this\\=';
+i.e., do not alter quote marks.  The default value nil acts like
+`curve' if curved single quotes are displayable, and like `grave'
+otherwise.  */);
   Vtext_quoting_style = Qnil;
 
   DEFVAR_BOOL ("internal--text-quoting-flag", text_quoting_flag,
diff --git a/src/editfns.c b/src/editfns.c
index 11a82c3..e9df09f 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -3974,8 +3974,6 @@ 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.  */
@@ -4454,14 +4452,6 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
 	}
       else
 	{
-	  /* Named constants for the UTF-8 encodings of U+2018 LEFT SINGLE
-	     QUOTATION MARK and U+2019 RIGHT SINGLE QUOTATION MARK.  */
-	  enum
-	  {
-	    uLSQM0 = 0xE2, uLSQM1 = 0x80, uLSQM2 = 0x98,
-	    /* uRSQM0 = 0xE2, uRSQM1 = 0x80, */ uRSQM2 = 0x99
-	  };
-
 	  unsigned char str[MAX_MULTIBYTE_LENGTH];
 
 	  if ((format_char == '`' || format_char == '\'')
@@ -4477,18 +4467,6 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message)
 	    }
 	  else if (format_char == '`' && quoting_style == STRAIGHT_QUOTING_STYLE)
 	    convsrc = "'";
-	  else if (format_char == uLSQM0 && CURVE_QUOTING_STYLE < quoting_style
-		   && multibyte_format
-		   && (unsigned char) format[0] == uLSQM1
-		   && ((unsigned char) format[1] == uLSQM2
-		       || (unsigned char) format[1] == uRSQM2))
-	    {
-	      convsrc = (((unsigned char) format[1] == uLSQM2
-			  && quoting_style == GRAVE_QUOTING_STYLE)
-			 ? "`" : "'");
-	      format += 2;
-	      memset (&discarded[format0 + 1 - format_start], 2, 2);
-	    }
 	  else
 	    {
 	      /* Copy a single character from format to buf.  */
diff --git a/src/lisp.h b/src/lisp.h
index de74a47..1fc6130 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -4198,9 +4198,6 @@ 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,
 
-- 
2.5.5


  parent reply	other threads:[~2016-05-04 23:49 UTC|newest]

Thread overview: 99+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-02 14:55 bug#23425: master branch: `message' wrongly corrupts ' to curly quote Alan Mackenzie
2016-05-02 16:25 ` Lars Ingebrigtsen
2016-05-02 16:41   ` Drew Adams
2016-05-02 17:53 ` Paul Eggert
2016-05-02 19:10   ` Alan Mackenzie
2016-05-03 15:17     ` Paul Eggert
2016-05-03 16:36       ` Drew Adams
2016-05-03 16:59         ` Eli Zaretskii
2016-05-03 15:38     ` Eli Zaretskii
2016-05-03 16:27       ` Alan Mackenzie
2016-05-03 16:55         ` Eli Zaretskii
2016-05-03 20:03           ` Alan Mackenzie
2016-05-03 20:49             ` Paul Eggert
2016-05-04 15:32             ` Eli Zaretskii
2016-05-04 16:48               ` Alan Mackenzie
2016-05-04 17:03                 ` Eli Zaretskii
2016-05-04 17:37                   ` Josh
2016-05-04 19:05                     ` Eli Zaretskii
2016-05-04 18:04                   ` Alan Mackenzie
2016-05-04 18:39                     ` Paul Eggert
2016-05-04 18:57                       ` Alan Mackenzie
2016-05-04 19:02                         ` John Wiegley
2016-05-04 21:34                         ` Paul Eggert
2016-05-04 21:50                         ` Paul Eggert
2016-05-04 23:49                       ` Paul Eggert [this message]
2016-05-05 15:51                         ` Eli Zaretskii
2016-05-10 14:41                           ` Paul Eggert
2017-05-31  1:07                             ` Glenn Morris
2017-05-31  1:42                               ` Paul Eggert
2017-05-31 21:24                                 ` Alan Mackenzie
2017-05-31 23:26                                   ` Paul Eggert
2017-06-02 21:02                                     ` Alan Mackenzie
2017-06-02 21:15                                       ` Dmitry Gutov
2017-06-03 21:10                                         ` Alan Mackenzie
     [not found]                                         ` <20170603211010.GD2130@acm.fritz.box>
2017-06-03 21:32                                           ` Dmitry Gutov
2017-06-02 21:47                                       ` Paul Eggert
2017-06-03  0:13                                         ` Glenn Morris
2017-06-03 21:01                                           ` Alan Mackenzie
2017-06-03 20:53                                         ` Alan Mackenzie
     [not found]                                         ` <20170603205331.GA2130@acm.fritz.box>
2017-06-04 21:01                                           ` Paul Eggert
2017-06-05 16:27                                             ` Alan Mackenzie
     [not found]                                             ` <20170605162737.GA30946@acm.fritz.box>
2017-06-05 18:19                                               ` Paul Eggert
     [not found]                                               ` <ac90b979-6a37-29c4-03b3-6322ac2cc11a@cs.ucla.edu>
2017-06-05 18:31                                                 ` Andreas Schwab
2017-06-05 20:37                                                 ` Alan Mackenzie
     [not found]                                                 ` <20170605203753.GB30946@acm.fritz.box>
2017-06-05 21:05                                                   ` Clément Pit-Claudel
2017-06-07 16:50                                                     ` Alan Mackenzie
2017-06-07 19:29                                                       ` Clément Pit-Claudel
2017-06-06  0:14                                                   ` Paul Eggert
2017-06-06  8:21                                                     ` Andreas Schwab
     [not found]                                                     ` <mvmtw3tsf05.fsf@suse.de>
2017-06-06 12:24                                                       ` Clément Pit-Claudel
     [not found]                                                       ` <fa92f34f-982b-e9a5-be21-188e694e38d9@gmail.com>
2017-06-06 13:55                                                         ` Yuri Khan
     [not found]                                                         ` <CAP_d_8X7V_G4g7emn_EPd_YYPKu2HfnDE+Q3FOPMGXpB4sEYSw@mail.gmail.com>
2017-06-06 18:21                                                           ` Clément Pit-Claudel
2017-06-06 18:59                                                             ` Yuri Khan
     [not found]                                                             ` <CAP_d_8X5OBsQQ=0+dj-qYFV3yEC4WZVMpyRw1KyiM0tvJUNFMw@mail.gmail.com>
2017-06-06 19:39                                                               ` Clément Pit-Claudel
     [not found]                                                               ` <10515b89-1c60-227e-ff3d-3127f59c0daf@gmail.com>
2017-06-07  4:57                                                                 ` Eli Zaretskii
2017-06-06 23:09                                                       ` Paul Eggert
2017-06-07  7:44                                                         ` Andreas Schwab
2017-06-07 18:17                                                           ` Paul Eggert
2017-06-08  8:04                                                             ` Andreas Schwab
2017-06-07 13:27                                                         ` Drew Adams
2017-06-07 19:13                                                     ` Alan Mackenzie
2017-06-07 19:27                                                       ` Clément Pit-Claudel
     [not found]                                                       ` <966db090-4aa1-231c-ef5a-370ece8905d1@gmail.com>
2017-06-07 19:33                                                         ` Dmitry Gutov
2017-06-07 19:51                                                         ` Alan Mackenzie
2017-06-07 20:33                                                         ` Alan Mackenzie
2017-06-07 23:28                                                       ` Paul Eggert
2017-06-08 17:34                                                         ` Alan Mackenzie
2017-06-08 20:17                                                           ` Paul Eggert
2017-06-09 19:41                                                             ` Alan Mackenzie
2017-06-09 20:17                                                               ` Drew Adams
2017-06-09 20:38                                                                 ` Alan Mackenzie
2017-06-09 21:05                                                                   ` Drew Adams
2017-06-09 21:44                                                               ` Paul Eggert
2017-06-09 22:51                                                                 ` Drew Adams
2017-06-10  0:20                                                                   ` Paul Eggert
2017-06-10 10:01                                                                     ` Alan Mackenzie
2017-06-10 10:52                                                                       ` David Engster
2017-06-10 11:48                                                                         ` Eli Zaretskii
2017-06-10 13:01                                                                         ` Alan Mackenzie
2017-06-10 13:39                                                                           ` Eli Zaretskii
2017-06-11 10:03                                                                             ` Alan Mackenzie
2017-06-11 14:37                                                                               ` Eli Zaretskii
2017-06-10 15:28                                                                           ` Dmitry Gutov
2017-06-01 16:56                                   ` Glenn Morris
2017-06-03 21:07                                     ` Alan Mackenzie
2016-05-04 18:46                     ` John Wiegley
2016-05-04 20:23                       ` Dmitry Gutov
2016-05-04 21:15                         ` John Wiegley
2016-05-04 22:19                           ` Lars Ingebrigtsen
2016-05-05  7:12                             ` Andreas Schwab
2016-05-05 17:05                         ` Eli Zaretskii
2016-05-05  8:06                       ` Alan Mackenzie
2016-05-05 17:06                       ` Eli Zaretskii
2016-05-05 23:46                         ` John Wiegley
2016-05-06  8:54                         ` Nicolas Petton
2016-05-04 19:08                     ` Eli Zaretskii
2016-05-04 21:49               ` Andreas Schwab
2017-06-09 20:31 ` Glenn Morris
2017-06-10  7:08   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b6310cb1-184c-8643-cced-1c25a7c13d5a@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=23425@debbugs.gnu.org \
    --cc=acm@muc.de \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).