Subject: bug#51040: No curved quotes in format-prompt and minibuffer-default-prompt-format

From: Stefan Kangas <[email-masked]>
Date: Tue, 12 Oct 2021 16:21:52 -0700

Eli Zaretskii <[email-masked]> writes:

> Ouch! what a mess do we have with this stuff!
>
>   . the doc string of text-quoting-style the function doesn't document
>     its return values, but refers to the variable, so it's easy to
>     conclude that it also returns nil
>   . that doc string says "effective style", without explaining the
>     special processing of nil
>   . the function is not in the ELisp manual, but the variable is,
>     twice(!)

Yeah, it's a mess.  I suggest we address the documentation issues on
emacs-28 with the attached patch.

I compared the duplicate text, and the only thing that was different is
that the word "variable" had been changed into "option".  So I deleted
the one in the wrong section and that incorrectly said "variable".
From cecc2e9dc32edba74d816c4fa327a288ed863006 Mon Sep 17 00:00:00 2001
From: Stefan Kangas <[email-masked]>
Date: Wed, 13 Oct 2021 00:56:39 +0200
Subject: [PATCH] Doc fixes for 'text-quoting-style'

* doc/lispref/help.texi (Keys in Documentation): Remove duplicate
entry for 'text-quoting-style'.  Document the function with the same
name instead.
* src/doc.c (Ftext_quoting_style): Doc fix: clarify the return values.
(syms_of_doc) <Vtext_quoting_style>: Doc fix: clarify that you should
not read the value of this variable directly; use Ftext_quoting_style
instead.  (Bug#51040)
---
 doc/lispref/help.texi | 25 ++++++-------------------
 src/doc.c             | 14 ++++++++++++--
 2 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/doc/lispref/help.texi b/doc/lispref/help.texi
index a788852de7..5133e20d85 100644
--- a/doc/lispref/help.texi
+++ b/doc/lispref/help.texi
@@ -353,25 +353,6 @@ Keys in Documentation
 @strong{Please note:} Each @samp{\} must be doubled when written in a
 string in Emacs Lisp.
 
-@defopt text-quoting-style
-@cindex curved quotes
-@cindex curly quotes
-The value of this variable is a symbol that specifies the style Emacs
-should use for single quotes in the wording of help and messages.  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}, 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 seem to be displayable, and like @code{grave}
-otherwise.
-
-This option is useful on platforms that have problems with curved
-quotes.  You can customize it freely according to your personal
-preference.
-@end defopt
-
 @defun substitute-command-keys string
 This function scans @var{string} for the above special sequences and
 replaces them by what they stand for, returning the result as a string.
@@ -477,6 +458,12 @@ Text Quoting Style
 preference.
 @end defopt
 
+@defun text-quoting-style
+You should not read the value of the variable
+@code{text-quoting-style} directly.  Instead, use this function with
+the same name to correctly handle the nil case described above.
+@end defun
+
 @node Describing Characters
 @section Describing Characters for Help Messages
 @cindex describe characters and events
diff --git a/src/doc.c b/src/doc.c
index 6be023bb93..4d5c693a29 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -681,7 +681,13 @@ default_to_grave_quoting_style (void)
 DEFUN ("text-quoting-style", Ftext_quoting_style,
        Stext_quoting_style, 0, 0, 0,
        doc: /* Return the current effective text quoting style.
-See variable `text-quoting-style'.  */)
+If the variable `text-quoting-style' is `grave', `straight' or
+`curve', just return that value.  If it is nil (the default), return
+`grave' if curved quotes cannot be displayed, otherwise return
+`quote'.  Any other value is invalid; in that case return `grave'.
+
+Note that in contrast to the variable `text-quoting-style', this
+function will never return nil.  */)
   (void)
 {
   /* Use grave accent and apostrophe `like this'.  */
@@ -731,7 +737,11 @@ syms_of_doc (void)
   `grave':    quote with grave accent and apostrophe \\=`like this\\=';
 	      i.e., do not alter the original quote marks.
   nil:        like `curve' if curved single quotes are displayable,
-	      and like `grave' otherwise.  This is the default.  */);
+	      and like `grave' otherwise.  This is the default.
+
+You should never read the value of this variable directly from a Lisp
+program.  Use the function `text-quoting-style' instead, as that will
+handle the default nil value.  */);
   Vtext_quoting_style = Qnil;
 
   DEFVAR_BOOL ("internal--text-quoting-flag", text_quoting_flag,
-- 
2.30.2