emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] Ignore escape characters for context-sensitive quotes (Bug#29812


From: Philipp Stephani
Subject: [PATCH] Ignore escape characters for context-sensitive quotes (Bug#29812)
Date: Sun, 31 Dec 2017 17:51:04 +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            |  1 +
 test/lisp/electric-tests.el | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/lisp/electric.el b/lisp/electric.el
index cee3562139..9473ef374d 100644
--- a/lisp/electric.el
+++ b/lisp/electric.el
@@ -504,6 +504,7 @@ electric-quote-post-self-insert-function
                             electric-quote-replace-double)
                         (save-excursion
                           (backward-char)
+                          (skip-syntax-backward "\\")
                           (or (bobp) (bolp)
                               (memq (char-before) (list q< q<<))
                               (memq (char-syntax (char-before))
diff --git a/test/lisp/electric-tests.el b/test/lisp/electric-tests.el
index 7df2449b9e..793cd7c5d3 100644
--- a/test/lisp/electric-tests.el
+++ b/test/lisp/electric-tests.el
@@ -735,6 +735,24 @@ electric-quote-replace-double-after-paren
   :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
-- 
2.15.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]