Subject: bug#20385: [PATCH] Support curved quotes in doc strings

From: Paul Eggert <[email-masked]>
Date: Tue, 19 May 2015 16:27:50 -0700

On 05/16/2015 01:27 AM, Dmitry Gutov wrote:
> Indeed, you will see the fancy quotes on the screen while editing 
> source files, even if something else will get saved to disk. font-lock 
> is handy that way. 

OK, I tried that, but it didn't work for me.  The attached patch works 
much of the time, but it causes annoying glitches on the screen (for an 
example see attached, created by "emacs -Q" and 'C-h b'; note the red 
color glitch after the double-quote).  Fiddling with the regexp doesn't 
help matters.  I'm afraid that font locking is so poorly documented (see 
Bug#20613) that I can't tell whether the color glitch is a bug in Emacs 
or in this patch's change to Emacs.

Even if I ignore the glitches, I found it disconcerting that the "wrong" 
characters were used to display text characters (or, from another point 
of view, that the buffer's contents were "wrong" compared to what was on 
the screen).  So I'm inclined to do something less tricky, e.g., simply 
replace characters in the *Help* buffer before displaying the buffer.  I 
plan to look into that next.
diff --git a/lisp/help-mode.el b/lisp/help-mode.el
index f99e916..4f53509 100644
--- a/lisp/help-mode.el
+++ b/lisp/help-mode.el
@@ -287,6 +287,12 @@ Commands:
 \\{help-mode-map}"
   (set (make-local-variable 'revert-buffer-function)
        'help-mode-revert-buffer)
+  (font-lock-add-keywords
+   nil '(("`\\([^[:space:]'`‘’][^'`‘’]*\\)?'"
+          . (0 (progn (compose-region (match-beginning 0)
+                                      (1+ (match-beginning 0)) ?‘)
+                      (compose-region (1- (match-end 0)) (match-end 0) ?’)
+                      nil)))))
   (set (make-local-variable 'bookmark-make-record-function)
        'help-bookmark-make-record))