Skip to content

Docstrings should not double-escape strings #320

Open
@yuhan0

Description

As pointed out in #197 (comment), when a docstring contains a quoted string, the contents of that string should already be double-escaped such that its printed representation is correctly escaped (and can be copy-pasted etc.).
This is the case for all built-in Emacs docs, I was especially tripped up by this section in the documentation of font-lock-keywords, rendered in helpful as:

For example, an element of the form highlights (if not already
highlighted):

 "\\\\\\=<foo\\\\\\=>"
  Discrete occurrences of "foo" in the value of the variable
  font-lock-keyword-face.

 ("fu\\\\(bar\\\\)" . 1)
  Substring "bar" within all occurrences of "fubar" in the
  value of font-lock-keyword-face.

and in its intended presentation by describe-variable as:

For example, an element of the form highlights (if not already
highlighted):

 "\\<foo\\>"
  Discrete occurrences of "foo" in the value of the variable
  ‘font-lock-keyword-face’.

 ("fu\\(bar\\)" . 1)
  Substring "bar" within all occurrences of "fubar" in the
  value of ‘font-lock-keyword-face’.

The motivating example for the change was in fact an inaccuracy in one of Counsel's docstrings, and has since been fixed:abo-abo/swiper@1160924

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions