]> git.eshelyaron.com Git - emacs.git/commitdiff
Ignore escape characters for context-sensitive quotes (Bug#29812)
authorPhilipp Stephani <phst@google.com>
Sun, 31 Dec 2017 16:43:43 +0000 (17:43 +0100)
committerPhilipp Stephani <phst@google.com>
Sun, 7 Jan 2018 12:52:59 +0000 (13:52 +0100)
* lisp/electric.el (electric-quote-post-self-insert-function): Skip
over escape characters when determining whether a context-sensitive
quote should be opening or closing.

* test/lisp/electric-tests.el
(electric-quote-replace-double-escaped-open)
(electric-quote-replace-double-escaped-close): New unit tests.

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

index 8343d8c1b13781f513f04ca9c519bcdf25f6f2a0..c00e7c00a5930c1583691f3d83b34dc0b14feb6e 100644 (file)
@@ -505,6 +505,7 @@ This requotes when a quoting key is typed."
                                  (eq last-command-event ?\")))
                         (save-excursion
                           (backward-char)
+                          (skip-syntax-backward "\\")
                           (or (bobp) (bolp)
                               (memq (char-before) (list q< q<<))
                               (memq (char-syntax (char-before))
index 44bdbc7b8c8def1a2a0471b176597a2f0a8bfa0e..60191bfbbaa899ffecc29acbed3ae1ec5fa1f03f 100644 (file)
@@ -742,6 +742,24 @@ baz\"\""
   :bindings '((electric-quote-replace-double . t))
   :test-in-comments nil :test-in-strings nil)
 
+(define-electric-pair-test electric-quote-replace-double-escaped-open
+  "foo \\" "-----\"" :expected-string "foo \\“"
+  :expected-point 7 :modes '(emacs-lisp-mode c-mode)
+  :fixture-fn #'electric-quote-local-mode
+  :bindings '((electric-quote-replace-double . t)
+              (electric-quote-comment . t)
+              (electric-quote-string . t))
+  :test-in-comments t :test-in-strings t :test-in-code nil)
+
+(define-electric-pair-test electric-quote-replace-double-escaped-close
+  "foo \\“foo\\" "----------\"" :expected-string "foo \\“foo\\”"
+  :expected-point 12 :modes '(emacs-lisp-mode c-mode)
+  :fixture-fn #'electric-quote-local-mode
+  :bindings '((electric-quote-replace-double . t)
+              (electric-quote-comment . t)
+              (electric-quote-string . t))
+  :test-in-comments t :test-in-strings t :test-in-code 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