Subject: Re: bug#20545: New minor mode Electric Punct

From: Paul Eggert <[email-masked]>
Date: Sat, 16 May 2015 14:20:39 -0700

Paul Eggert wrote:
> A proposed patch is attached; it worked for me.

On further thought, the code affects global settings so it should be done only 
if FRAME is nil.  Also, it should treat double-quotes like single-quotes, and 
the ASCII approximations should use straight quotes.  This code is separable 
from Bug#20545, and is also separable from the issue of how to quote in doc 
strings, as the code is useful whenever text with English quotes appears on an 
obsolescent display lacking them.  So I installed the attached patch.
From a92e964a9809ada92b29b23ab6191fc7f3faad4d Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Sat, 16 May 2015 13:47:36 -0700
Subject: [PATCH] ASCIIfy curved quotes on displays lacking them

* lisp/international/mule-cmds.el (set-locale-environment):
If curved quotes don't work, display straight ASCII approximations
(Bug#20545).
---
 lisp/international/mule-cmds.el | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index fd892aa..4b63cb8 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -2708,6 +2708,14 @@ See also `locale-charset-language-names', `locale-language-names',
 	(set-terminal-coding-system 'utf-8)
 	(set-keyboard-coding-system 'utf-8)))
 
+    ;; If curved quotes don't work, display straight ASCII approximations.
+    (unless frame
+      (dolist (char-repl '((?‘ . [?\']) (?’ . [?\']) (?“ . [?\"]) (?” . [?\"])))
+        (when (not (char-displayable-p (car char-repl)))
+          (or standard-display-table
+              (setq standard-display-table (make-display-table)))
+          (aset standard-display-table (car char-repl) (cdr char-repl)))))
+
     ;; Default to A4 paper if we're not in a C, POSIX or US locale.
     ;; (See comments in Flocale_info.)
     (unless frame
-- 
2.1.0