Subject: Re: bug#24759: 25.1.50; electric-quote-mode

From: Paul Eggert <[email-masked]>
Date: Sun, 23 Oct 2016 01:15:47 -0700

Eli Zaretskii wrote:
> So I think we should indeed remove the electric--insertable-p test in
> electric-quote-mode, on the emacs-25 branch.

OK, done with the attached.
>From da6bd602c8603a23c6c63e4d4676333d91388be0 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Sun, 23 Oct 2016 01:14:23 -0700
Subject: [PATCH] electric-quote mode no longer worries about coding

* doc/emacs/text.texi (Quotation Marks), etc/NEWS: Document this.
* lisp/electric.el (electric--insertable-p): Remove.
All uses removed (Bug#24759).
---
 doc/emacs/text.texi |  4 +---
 etc/NEWS            |  6 ++++++
 lisp/electric.el    | 21 ++++-----------------
 3 files changed, 11 insertions(+), 20 deletions(-)

diff --git a/doc/emacs/text.texi b/doc/emacs/text.texi
index 579f788..7fa0804 100644
--- a/doc/emacs/text.texi
+++ b/doc/emacs/text.texi
@@ -422,9 +422,7 @@ Quotation Marks
 
   Electric Quote mode makes it easier to type curved quotes.  As you
 type characters it optionally converts @t{`} to @t{‘}, @t{'} to @t{’},
-@t{``} to @t{“}, and @t{''} to @t{”}.  These conversions are
-suppressed in buffers whose coding systems cannot represent curved
-quote characters.
+@t{``} to @t{“}, and @t{''} to @t{”}.
 
 @vindex electric-quote-paragraph
 @vindex electric-quote-comment
diff --git a/etc/NEWS b/etc/NEWS
index 5b89639..a5bcb8d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -38,6 +38,12 @@ fontsets if the default font supports these characters.  Set this
 variable to nil to disable the new behavior and get back the old
 behavior.
 
++++
+** 'electric-quote-mode' is no longer suppressed in a buffer whose
+whose coding system cannot represent curved quote characters.
+Instead, users can deal with the unrepresentable characters in the
+usual way when they save the buffer.
+
 ---
 ** New variable 'inhibit-compacting-font-caches'.
 Set this variable to a non-nil value to speed up display of characters
diff --git a/lisp/electric.el b/lisp/electric.el
index b6697e0..ab9770b 100644
--- a/lisp/electric.el
+++ b/lisp/electric.el
@@ -430,12 +430,6 @@ electric-quote-paragraph
   :version "25.1"
   :type 'boolean :safe 'booleanp :group 'electricity)
 
-(defun electric--insertable-p (string)
-  (or (not buffer-file-coding-system)
-      (eq (coding-system-base buffer-file-coding-system) 'undecided)
-      (not (unencodable-char-position nil nil buffer-file-coding-system
-                                      nil string))))
-
 (defun electric-quote-post-self-insert-function ()
   "Function that `electric-quote-mode' adds to `post-self-insert-hook'.
 This requotes when a quoting key is typed."
@@ -460,8 +454,7 @@ electric-quote-post-self-insert-function
       (when start
         (save-excursion
           (if (eq last-command-event ?\`)
-              (cond ((and (electric--insertable-p "“")
-                          (search-backward "‘`" (- (point) 2) t))
+              (cond ((search-backward "‘`" (- (point) 2) t)
                      (replace-match "“")
                      (when (and electric-pair-mode
                                 (eq (cdr-safe
@@ -469,16 +462,13 @@ electric-quote-post-self-insert-function
                                     (char-after)))
                        (delete-char 1))
                      (setq last-command-event ?“))
-                    ((and (electric--insertable-p "‘")
-                          (search-backward "`" (1- (point)) t))
+                    ((search-backward "`" (1- (point)) t)
                      (replace-match "‘")
                      (setq last-command-event ?‘)))
-            (cond ((and (electric--insertable-p "”")
-                        (search-backward "’'" (- (point) 2) t))
+            (cond ((search-backward "’'" (- (point) 2) t)
                    (replace-match "”")
                    (setq last-command-event ?”))
-                  ((and (electric--insertable-p "’")
-                        (search-backward "'" (1- (point)) t))
+                  ((search-backward "'" (1- (point)) t)
                    (replace-match "’")
                    (setq last-command-event ?’)))))))))
 
@@ -497,9 +487,6 @@ electric-quote-mode
 `electric-quote-comment', `electric-quote-string', and
 `electric-quote-paragraph'.
 
-Electric quoting is suppressed in a buffer whose coding system
-cannot represent the replacement characters.
-
 This is a global minor mode.  To toggle the mode in a single buffer,
 use `electric-quote-local-mode'."
   :global t :group 'electricity
-- 
2.7.4