Commit 6735df44 authored by Philipp Stephani's avatar Philipp Stephani
Browse files

Ignore escape characters for context-sensitive quotes (Bug#29812)

* 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.
parent f07c325d
......@@ -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))
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment