(defun foo ()

The ASCII quotes in this docstring are displayed as typographical quotes by describe-function.

Is it possible to have them displayed in their original form?


Basil's answer covers the needs of the end-user.

If you're writing elisp docstrings for other people, however, you (unfortunately) can't rely on everyone configuring text-quoting-style to grave, so when you need to ensure that quotes are not converted, you have to use an escaping syntax:

(defun foo ()
  "Something about \\='foo")

Will ensure that, regardless of text-quoting-style, the docstring is rendered like so:

Something about 'foo

This is very important if your docstring contains elisp code samples which include quotes, as the default behaviour would render such code invalid (and in a way which might be incredibly difficult for users to discern).

See also Basil's link to (elisp) Text Quoting Style, which provides another example.



(setq text-quoting-style 'grave)

and see the answer by phils.

Is it possible to have them displayed in their original form?

Yes, see (elisp) Text Quoting Style, specifically the description of the user option text-quoting-style:

text-quoting-style is a variable defined in ‘doc.c’.
Its value is nil

  Probably introduced at or before Emacs version 25.1.

Style to use for single quotes in help and messages.
Its value should be a symbol.  It works by substituting certain single
quotes for grave accent and apostrophe.  This is done in help output
(but not for display of Info manuals) and in functions like ‘message’
and ‘format-message’.  It is not done in ‘format’.

‘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';
i.e., do not alter quote marks.  The default value nil acts like
‘curve’ if curved single quotes are displayable, and like ‘grave’

See also the relevant paragraph of (emacs) Text Display:

   Emacs tries to determine if the curved quotes ‘‘’ and ‘’’ can be
displayed on the current display.  By default, if this seems to be so,
then Emacs will translate the ASCII quotes (‘`’ and ‘'’), when they
appear in messages and help texts, to these curved quotes.  You can
influence or inhibit this translation by customizing the user option
‘text-quoting-style’ (see (elisp)Keys in Documentation).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.