unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / Atom feed
* [PATCH] emacs docs: rstdoc.el: consistent single quote conversions
@ 2020-10-09  7:32 Tomi Ollila
  2020-10-09  9:44 ` David Bremner
  0 siblings, 1 reply; 5+ messages in thread
From: Tomi Ollila @ 2020-10-09  7:32 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

With text-quoting-style 'grave keeps "'" and "`" quotes unaltered
for further processing done by this code (regardless of locale...).
The tools that read the reStructuredText markup generated can do
their styling instead.

Added temporary conversions of ' and ` to \001 and \002 so that
's and `s outside of `...' and `...` are converted separately
('s restored back to ' and `s converted to \`).

Both `...' and `...` are finally "converted" to `...` (not ``...``).
https://docutils.sourceforge.io/docs/user/rst/quickref.html documents
that as `interpreted text`:

 "The rendering and meaning of interpreted text is domain- or
  application-dependent. It can be used for things like index
  entries or explicit descriptive markup (like program identifiers)."

Which looks pretty much right.

---

Overhauled version of id:20200413104108.10837-1-tomi.ollila@iki.fi

When the default 'curve text quoting style was effective in UTF-8
locale, I experienced inconsistent conversions from `' to ‘’;
sometimes conversions weren't done (one more reason to use 'grave :)
---
 emacs/rstdoc.el | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/emacs/rstdoc.el b/emacs/rstdoc.el
index 63fa2794..4221f142 100644
--- a/emacs/rstdoc.el
+++ b/emacs/rstdoc.el
@@ -40,6 +40,7 @@ (defun rstdoc-extract (in-file out-file)
   "Write docstrings from IN-FILE to OUT-FILE."
   (load-file in-file)
   (let* ((definitions (cdr (assoc (expand-file-name in-file) load-history)))
+	 (text-quoting-style 'grave)
 	 (doc-hash (make-hash-table :test 'eq)))
     (mapc
      (lambda (elt)
@@ -65,11 +66,14 @@ (defun rstdoc--insert-docstring (symbol docstring)
   (insert "\n"))
 
 (defvar rst--escape-alist
-  '(("\\\\='" . "\\\\'")
-    ("\\([^\\]\\)'" . "\\1`")
-    ("^[[:space:]\t]*$" . "|br|")
-    ("^[[:space:]\t]" . "|indent| "))
-  "List of (regex . replacement) pairs.")
+  '( ("\\\\='" . "\001")
+     ("`\\([^\n`']*\\)[`']" . "\002\\1\002") ;; good enough for now...
+     ("`" . "\\\\`")
+     ("\001" . "'")
+     ("\002" . "`")
+     ("^[[:space:]]*$" . "|br|")
+     ("^[[:space:]]" . "|indent| "))
+    "list of (regex . replacement) pairs")
 
 (defun rstdoc--rst-quote-string (str)
   (with-temp-buffer
-- 
2.25.1\r

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

* Re: [PATCH] emacs docs: rstdoc.el: consistent single quote conversions
  2020-10-09  7:32 [PATCH] emacs docs: rstdoc.el: consistent single quote conversions Tomi Ollila
@ 2020-10-09  9:44 ` David Bremner
  2020-10-13 15:00   ` Tomi Ollila
  2020-10-17 11:29   ` David Bremner
  0 siblings, 2 replies; 5+ messages in thread
From: David Bremner @ 2020-10-09  9:44 UTC (permalink / raw)
  To: Tomi Ollila, notmuch; +Cc: tomi.ollila

Tomi Ollila <tomi.ollila@iki.fi> writes:

> With text-quoting-style 'grave keeps "'" and "`" quotes unaltered
> for further processing done by this code (regardless of locale...).
> The tools that read the reStructuredText markup generated can do
> their styling instead.

Not a direct comment on your patch, but should we be setting some fixed
locale when running emacs at build time?

d

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

* Re: [PATCH] emacs docs: rstdoc.el: consistent single quote conversions
  2020-10-09  9:44 ` David Bremner
@ 2020-10-13 15:00   ` Tomi Ollila
  2020-10-17 11:29   ` David Bremner
  1 sibling, 0 replies; 5+ messages in thread
From: Tomi Ollila @ 2020-10-13 15:00 UTC (permalink / raw)
  To: David Bremner, notmuch

On Fri, Oct 09 2020, David Bremner wrote:

> Tomi Ollila <tomi.ollila@iki.fi> writes:
>
>> With text-quoting-style 'grave keeps "'" and "`" quotes unaltered
>> for further processing done by this code (regardless of locale...).
>> The tools that read the reStructuredText markup generated can do
>> their styling instead.
>
> Not a direct comment on your patch, but should we be setting some fixed
> locale when running emacs at build time?

If we did that, probably "C" would be the only choice (next could be
en_US.UTF-8, but at least I don't like the defaults that sets).

What would be better that we can ensure build reproducibility whatever
the locale settings are (I want to have my hilarious fi_FI.UTF-8 messages ;).

>
> d

Tomi

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

* Re: [PATCH] emacs docs: rstdoc.el: consistent single quote conversions
  2020-10-09  9:44 ` David Bremner
  2020-10-13 15:00   ` Tomi Ollila
@ 2020-10-17 11:29   ` David Bremner
  2020-10-21  9:59     ` David Bremner
  1 sibling, 1 reply; 5+ messages in thread
From: David Bremner @ 2020-10-17 11:29 UTC (permalink / raw)
  To: Tomi Ollila, notmuch; +Cc: tomi.ollila

David Bremner <david@tethera.net> writes:

> Tomi Ollila <tomi.ollila@iki.fi> writes:
>
>> With text-quoting-style 'grave keeps "'" and "`" quotes unaltered
>> for further processing done by this code (regardless of locale...).
>> The tools that read the reStructuredText markup generated can do
>> their styling instead.
>
> Not a direct comment on your patch, but should we be setting some fixed
> locale when running emacs at build time?

Now that I try, this doesn't apply to master.

d

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

* Re: [PATCH] emacs docs: rstdoc.el: consistent single quote conversions
  2020-10-17 11:29   ` David Bremner
@ 2020-10-21  9:59     ` David Bremner
  0 siblings, 0 replies; 5+ messages in thread
From: David Bremner @ 2020-10-21  9:59 UTC (permalink / raw)
  To: Tomi Ollila, notmuch; +Cc: tomi.ollila

David Bremner <david@tethera.net> writes:

> David Bremner <david@tethera.net> writes:
>
>> Tomi Ollila <tomi.ollila@iki.fi> writes:
>>
>>> With text-quoting-style 'grave keeps "'" and "`" quotes unaltered
>>> for further processing done by this code (regardless of locale...).
>>> The tools that read the reStructuredText markup generated can do
>>> their styling instead.
>>
>> Not a direct comment on your patch, but should we be setting some fixed
>> locale when running emacs at build time?
>
> Now that I try, this doesn't apply to master.

As you surmised on IRC, it was a line ending problem, that I solved with
my previously developed script. I guess I should include said script in
our devel/ collection. Or someone(TM) could fix mailman.

d

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

end of thread, other threads:[~2020-10-21 10:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-09  7:32 [PATCH] emacs docs: rstdoc.el: consistent single quote conversions Tomi Ollila
2020-10-09  9:44 ` David Bremner
2020-10-13 15:00   ` Tomi Ollila
2020-10-17 11:29   ` David Bremner
2020-10-21  9:59     ` David Bremner

unofficial mirror of notmuch@notmuchmail.org

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/notmuch/0 notmuch/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 notmuch notmuch/ https://yhetil.org/notmuch \
		notmuch@notmuchmail.org
	public-inbox-index notmuch

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.mail.notmuch.general
	nntp://news.gmane.io/gmane.mail.notmuch.general


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git