all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Paul Eggert <eggert@cs.ucla.edu>, emacs-devel@gnu.org
Subject: Re: [Emacs-diffs] master 9d35bb8: Fix minor quoting problems in doc strings
Date: Wed, 20 May 2015 15:25:10 +0300	[thread overview]
Message-ID: <555C7D26.8030909@yandex.ru> (raw)
In-Reply-To: <555BF61D.40202@cs.ucla.edu>

On 05/20/2015 05:49 AM, Paul Eggert wrote:

> Although the quotes that we want to curl are paired, there are other
> stray grave accents and apostrophes that we shouldn't curl.

Probably. But if they're rare enough, having to escape won't be too 
annoying.

> Are you sure?  The first grave accent looks like a quasiquote, so there
> shouldn't be a closing apostrophe.  Those commas are clues that it's a
> quasiquote.

Indeed (I corrected myself later). If this kind of quasiquote is a 
popular kind of exception, we can handle it programmatically:

- If there's a opening paren after the backtick,
- And there's no apostrophe after the matching closing paren,

don't turn the backtick into the curly quote, and continue matching 
right after the closing paren.

If could be implemented in the form FACENAME in font-lock-keywords while 
keeping the matcher to be a regexp, but a custom matching function seems 
more appropriate, to catch any apostrophes (straight quotes) inside the 
form. See the patch.

> Here's my current draft regexp to catch the quotations we want to curl:
>
>    `\\([^[:space:]'`‘’][^'`‘’]*\\)?'
>
> A bit tricky, but could be worse.  Newlines are allowed, as some doc
> strings break these quotes across line boundaries (e.g., info node
> references).

Why not allow curly quotes inside? They don't introduce any syntax 
ambiguity.


diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index f99e916..a0b7a6d 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -279,6 +279,19 @@ The format is (FUNCTION ARGS...).")
  \f
  (defvar bookmark-make-record-function)

+(defun help--match-quoted-code (limit)
+  (while (search-forward "`" limit t)
+    (let ((beg (point))
+          forward-sexp-function)
+      (when
+          (if (not (eq (char-after) ?\())
+              (re-search-forward "\\=\\([^[:space:]'`‘’][^'`‘’]*\\)?'" 
limit t)
+            (forward-sexp)
+            (eq (char-after) ?'))
+        (compose-region (1- beg) beg ?‘)
+        (compose-region (1- (point)) (point) ?’))))
+  nil)
+
  ;;;###autoload
  (define-derived-mode help-mode special-mode "Help"
    "Major mode for viewing help text and navigating references in it.
@@ -287,6 +300,7 @@ Commands:
  \\{help-mode-map}"
    (set (make-local-variable 'revert-buffer-function)
         'help-mode-revert-buffer)
+  (setq font-lock-defaults '(((help--match-quoted-code)) t))
    (set (make-local-variable 'bookmark-make-record-function)
         'help-bookmark-make-record))





  reply	other threads:[~2015-05-20 12:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20150519220123.30678.22605@vcs.savannah.gnu.org>
     [not found] ` <E1YupZj-000803-T3@vcs.savannah.gnu.org>
2015-05-19 22:30   ` [Emacs-diffs] master 9d35bb8: Fix minor quoting problems in doc strings Dmitry Gutov
2015-05-19 23:18     ` Paul Eggert
2015-05-20  1:16       ` Dmitry Gutov
2015-05-20  2:14         ` Paul Eggert
2015-05-20  2:36           ` Dmitry Gutov
2015-05-20  2:45             ` Dmitry Gutov
2015-05-20  2:49             ` Paul Eggert
2015-05-20 12:25               ` Dmitry Gutov [this message]
2015-05-20 12:50           ` Stefan Monnier
2015-05-21  7:36             ` Paul Eggert
2015-05-21 10:05               ` Dmitry Gutov
2015-05-21 14:44                 ` Paul Eggert
2015-05-20  4:23     ` Yuri Khan
2015-05-20 15:36   ` Glenn Morris
2015-05-21  5:18     ` Paul Eggert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=555C7D26.8030909@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=eggert@cs.ucla.edu \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.