]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix a small bug in electric quoting.
authorPhilipp Stephani <phst@google.com>
Sun, 31 Dec 2017 17:05:03 +0000 (18:05 +0100)
committerPhilipp Stephani <phst@google.com>
Sun, 7 Jan 2018 12:50:03 +0000 (13:50 +0100)
Before this commit, if 'electric-quote-replace-double' is non-nil,
typing " '" turned into " ‘" even if
'electric-quote-context-sensitive' was nil.

* lisp/electric.el (electric-quote-post-self-insert-function): Insert
context-sensitive double quote only if the last character is actually
a double quote character.

* test/lisp/electric-tests.el
(electric-quote-replace-double-no-context-single): New unit test.

lisp/electric.el
test/lisp/electric-tests.el

index a694665dbbf0ade6298132e0adcd3668c6bfa1d9..8343d8c1b13781f513f04ca9c519bcdf25f6f2a0 100644 (file)
@@ -501,7 +501,8 @@ This requotes when a quoting key is typed."
          (let ((backtick ?\`))
            (if (or (eq last-command-event ?\`)
                    (and (or electric-quote-context-sensitive
-                            electric-quote-replace-double)
+                            (and electric-quote-replace-double
+                                 (eq last-command-event ?\")))
                         (save-excursion
                           (backward-char)
                           (or (bobp) (bolp)
index 83e0c678e3b61471f14a675771ed6828a1fca2cb..44bdbc7b8c8def1a2a0471b176597a2f0a8bfa0e 100644 (file)
@@ -735,6 +735,13 @@ baz\"\""
   :bindings '((electric-quote-replace-double . t))
   :test-in-comments nil :test-in-strings nil)
 
+(define-electric-pair-test electric-quote-replace-double-no-context-single
+  " " "-'" :expected-string " ’" :expected-point 3
+  :modes '(text-mode)
+  :fixture-fn #'electric-quote-local-mode
+  :bindings '((electric-quote-replace-double . t))
+  :test-in-comments nil :test-in-strings nil)
+
 ;; Simulate ‘markdown-mode’: it sets both ‘comment-start’ and
 ;; ‘comment-use-syntax’, but derives from ‘text-mode’.
 (define-electric-pair-test electric-quote-markdown-in-text