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

From: Eli Zaretskii <[email-masked]>
Date: Tue, 12 Oct 2021 15:52:48 +0300

> From: Stefan Kangas <[email-masked]>
> Date: Mon, 11 Oct 2021 13:58:58 -0700
> Cc: [email-masked]
> 
> Lars Ingebrigtsen <[email-masked]> writes:
> 
> > Yeah, having a separate function for this would be good, because those
> > bits are pretty confusing.  But as you say, in this `format-prompt'
> > case, using `substitute-command-keys' is probably the right thing, since
> > we could be actually using key defs in the prompt.
> 
> OK, so here's what I propose.  The first patch adds a function
> `substitute-quotes' and could go to master, the second one changes
> `format-prompt' to use `substitute-command-keys' and could go to
> emacs-28.
> 
> From e455d509a27b2705f006bc2111228a9a8b8df0b4 Mon Sep 17 00:00:00 2001
> From: Stefan Kangas <[email-masked]>
> Date: Mon, 11 Oct 2021 22:46:31 +0200
> Subject: [PATCH 1/2] New function substitute-quotes
> 
> * lisp/help.el (substitute-quotes): New function.  (Bug#51040)
> * lisp/cedet/srecode/srt-mode.el (srecode-macro-help):
> * lisp/cus-theme.el (describe-theme-1):
> * lisp/emacs-lisp/cl-extra.el (cl--describe-class):
> * lisp/emacs-lisp/eieio-opt.el (eieio-help-constructor):
> * lisp/emacs-lisp/package.el (describe-package-1):
> * lisp/help-fns.el (help-fns--parent-mode, help-fns--var-risky)
> (help-fns--var-file-local, help-fns--var-bufferlocal)
> (describe-face):
> * lisp/help.el (substitute-command-keys):
> * lisp/progmodes/octave.el (octave-help): Use the new function
> instead of 'substitute-command-keys'.
> * test/lisp/help-tests.el (help-tests-substitute-quotes): New test.

Shouldn't substitute-quotes be documented?

> +(defun substitute-quotes (string)
> +  "Substitute quote characters for display.
> +Each grave accent \\=` is replaced by left quote, and each
> +apostrophe \\=' is replaced by right quote.  Left and right quote
> +characters are specified by ‘text-quoting-style’."
> +  (cond ((eq (text-quoting-style) 'curve)
> +         (replace-regexp-in-string
> +          "`" "‘"
> +          (replace-regexp-in-string "'" "’" string)))
> +        ((eq (text-quoting-style) 'straight)
> +         (replace-regexp-in-string "`" "'" string))

Aren't we supposed to use string-replace nowadays in these
situations?

Also, this seems to ignore the nil value of text-quoting-style?

And finally, I think the doc string of text-quoting-style should be
amended, since it says that variable's effect is limited to help text
and format-message, but now it seems its effect will spread much
wider.
> Subject: [PATCH 2/2] Use substitute-command-keys in format-prompt
> 
> * lisp/minibuffer.el (format-prompt): Use substitute-command-keys.
> (Bug#51040)

I'm not sure I understand the rationale for this.  This will change
the appearance of formatted prompts, won't it?  So people will now
have to use \\=' to get a literal apostrophe?  is that really what we
want, and if so, why?

Thanks.