Subject: bug#20545: New minor mode Electric Punct

From: Paul Eggert <[email-masked]>
Date: Wed, 13 May 2015 23:32:57 -0700

Eli Zaretskii wrote:
> I fear it will just be a source of confusion.

Well, 8-bit terminals are no longer that common (at least when developing Emacs) 
so it's no big deal either way, and as it's easier to do it without highlighting 
let's try it that way.  A proposed patch is attached; it worked for me.

Stefan Monnier wrote:
> The real test is when the environment
> uses utf-8 but the terminal's font fails to include the glyphs.

That can easily happen with other characters, but in practice nowadays I think 
everybody has glyphs for curved quotes.  This is in part due to Microsoft 
Windows putting curved quotes in their most-popular 8-bit character set starting 
with MS-Windows 1.0 in 1985.  This put a lot of pressure on everybody else to 
support these glyphs one way or another, and it has been thirty years now....
>From dd42a7ba816df0d209c0f1e965ee036c62c0337a Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Wed, 13 May 2015 23:15:23 -0700
Subject: [PATCH] Work better on terminals sans curved single quotes

* lisp/international/mule-cmds.el (set-locale-environment):
If single quotation marks are not displayable,
show ASCII approximations instead.
---
 lisp/international/mule-cmds.el | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lisp/international/mule-cmds.el b/lisp/international/mule-cmds.el
index fd892aa..2805671 100644
--- a/lisp/international/mule-cmds.el
+++ b/lisp/international/mule-cmds.el
@@ -2708,6 +2708,13 @@ See also `locale-charset-language-names', `locale-language-names',
 	(set-terminal-coding-system 'utf-8)
 	(set-keyboard-coding-system 'utf-8)))
 
+    ;; If single quotation marks don't work, display ASCII approximations.
+    (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