unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs doc: replace `...' with `...` in emacs docstrings for rst
@ 2020-04-13 10:41 Tomi Ollila
  2020-04-13 20:59 ` Tomi Ollila
  0 siblings, 1 reply; 2+ messages in thread
From: Tomi Ollila @ 2020-04-13 10:41 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

Previously ' without preceding \ was replaced with `, to make emacs
document content structure `...' to work with reStructuredText.

But there are also single uses of ' in parts of the extracted
docstrings, so better "restrict" the matching content to `[^']+'.

Dropped checking preceding \ before ' -- it is not needed anymore;
there is now one \' in the docstrings, but outside `...'.

Note: In UTF-8 locales ` and ' may be replaced by some (arguably)
better looking unicode counterparts (by emacs).
---

This also "avoids" the bug building emacs/notmuch-parser.rsti in
Debian 10. The doc content with "... SP's ..." no longer matches
the re which caused emacs to barf then in (replace-match) (*)
there. The bug is still a mystery (and may stay so).

(* used (setq debug-on-error t) to dig a bit of the problem)

 emacs/rstdoc.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/emacs/rstdoc.el b/emacs/rstdoc.el
index 2225aefc..94596061 100644
--- a/emacs/rstdoc.el
+++ b/emacs/rstdoc.el
@@ -68,7 +68,7 @@ (defun rstdoc--insert-docstring (symbol docstring)
 
 (defvar rst--escape-alist
   '( ("\\\\='" . "\\\\'")
-     ("\\([^\\]\\)'" . "\\1`")
+     ("`\\([^']+\\)'" . "`\\1`")
      ("^[[:space:]\t]*$" . "|br|")
      ("^[[:space:]\t]" . "|indent| "))
     "list of (regex . replacement) pairs")
-- 
2.25.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] emacs doc: replace `...' with `...` in emacs docstrings for rst
  2020-04-13 10:41 [PATCH] emacs doc: replace `...' with `...` in emacs docstrings for rst Tomi Ollila
@ 2020-04-13 20:59 ` Tomi Ollila
  0 siblings, 0 replies; 2+ messages in thread
From: Tomi Ollila @ 2020-04-13 20:59 UTC (permalink / raw)
  To: notmuch

On Mon, Apr 13 2020, Tomi Ollila wrote:

> Previously ' without preceding \ was replaced with `, to make emacs
> document content structure `...' to work with reStructuredText.

The change is good, but comment message crap. 

While trying to make rstdoc.el to load elisp code so that in docstrings
single quotes (') were not changed to their better-looking unicode
counterparts I notices that in `...' the ' in that is not converted
(since it is syntax-highlighted internally by emacs). 

Since that the original version where 's not preceded by \ are converted.
(as rest are already changed) -- ¡¡¡unless the locale is C!!!.

So we really are better just converting `...' to `...` (If we had `:s
w/o ...' then those should be escaped -- but (so far) we don't -- 
doing those is not trivial, but possible).

I'll resend this w/ different commit message later.

(but please review and comment if there is anything wrong before that =)

Tomi

>
> But there are also single uses of ' in parts of the extracted
> docstrings, so better "restrict" the matching content to `[^']+'.
>
> Dropped checking preceding \ before ' -- it is not needed anymore;
> there is now one \' in the docstrings, but outside `...'.
>
> Note: In UTF-8 locales ` and ' may be replaced by some (arguably)
> better looking unicode counterparts (by emacs).
> ---
>
> This also "avoids" the bug building emacs/notmuch-parser.rsti in
> Debian 10. The doc content with "... SP's ..." no longer matches
> the re which caused emacs to barf then in (replace-match) (*)
> there. The bug is still a mystery (and may stay so).
>
> (* used (setq debug-on-error t) to dig a bit of the problem)
>
>  emacs/rstdoc.el | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/emacs/rstdoc.el b/emacs/rstdoc.el
> index 2225aefc..94596061 100644
> --- a/emacs/rstdoc.el
> +++ b/emacs/rstdoc.el
> @@ -68,7 +68,7 @@ (defun rstdoc--insert-docstring (symbol docstring)
>  
>  (defvar rst--escape-alist
>    '( ("\\\\='" . "\\\\'")
> -     ("\\([^\\]\\)'" . "\\1`")
> +     ("`\\([^']+\\)'" . "`\\1`")
>       ("^[[:space:]\t]*$" . "|br|")
>       ("^[[:space:]\t]" . "|indent| "))
>      "list of (regex . replacement) pairs")
> -- 
> 2.25.2

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-13 21:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-13 10:41 [PATCH] emacs doc: replace `...' with `...` in emacs docstrings for rst Tomi Ollila
2020-04-13 20:59 ` Tomi Ollila

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.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).