aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Stephani2017-12-31 18:05:03 +0100
committerPhilipp Stephani2018-01-07 13:50:03 +0100
commitf07c325d1f49e4b722f76aa730ac5d084bd0e77a (patch)
tree99369fe6c5f1a252e856dac51c64dc4a4ee71b92
parent151496a4b96430924bc148f85b9c8471d1e132b1 (diff)
downloademacs-f07c325d1f49e4b722f76aa730ac5d084bd0e77a.tar.gz
emacs-f07c325d1f49e4b722f76aa730ac5d084bd0e77a.zip
Fix a small bug in electric quoting.
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.
-rw-r--r--lisp/electric.el3
-rw-r--r--test/lisp/electric-tests.el7
2 files changed, 9 insertions, 1 deletions
diff --git a/lisp/electric.el b/lisp/electric.el
index a694665dbbf..8343d8c1b13 100644
--- a/lisp/electric.el
+++ b/lisp/electric.el
@@ -501,7 +501,8 @@ This requotes when a quoting key is typed."
501 (let ((backtick ?\`)) 501 (let ((backtick ?\`))
502 (if (or (eq last-command-event ?\`) 502 (if (or (eq last-command-event ?\`)
503 (and (or electric-quote-context-sensitive 503 (and (or electric-quote-context-sensitive
504 electric-quote-replace-double) 504 (and electric-quote-replace-double
505 (eq last-command-event ?\")))
505 (save-excursion 506 (save-excursion
506 (backward-char) 507 (backward-char)
507 (or (bobp) (bolp) 508 (or (bobp) (bolp)
diff --git a/test/lisp/electric-tests.el b/test/lisp/electric-tests.el
index 83e0c678e3b..44bdbc7b8c8 100644
--- a/test/lisp/electric-tests.el
+++ b/test/lisp/electric-tests.el
@@ -735,6 +735,13 @@ baz\"\""
735 :bindings '((electric-quote-replace-double . t)) 735 :bindings '((electric-quote-replace-double . t))
736 :test-in-comments nil :test-in-strings nil) 736 :test-in-comments nil :test-in-strings nil)
737 737
738(define-electric-pair-test electric-quote-replace-double-no-context-single
739 " " "-'" :expected-string " ’" :expected-point 3
740 :modes '(text-mode)
741 :fixture-fn #'electric-quote-local-mode
742 :bindings '((electric-quote-replace-double . t))
743 :test-in-comments nil :test-in-strings nil)
744
738;; Simulate ‘markdown-mode’: it sets both ‘comment-start’ and 745;; Simulate ‘markdown-mode’: it sets both ‘comment-start’ and
739;; ‘comment-use-syntax’, but derives from ‘text-mode’. 746;; ‘comment-use-syntax’, but derives from ‘text-mode’.
740(define-electric-pair-test electric-quote-markdown-in-text 747(define-electric-pair-test electric-quote-markdown-in-text