diff options
| author | Philipp Stephani | 2017-12-31 17:43:43 +0100 |
|---|---|---|
| committer | Philipp Stephani | 2018-01-07 13:52:59 +0100 |
| commit | 6735df4443fe0aa60862a95c38746edf2b053862 (patch) | |
| tree | 759392dc48f2ce4c60ba7eaa1476c2334a51f331 | |
| parent | f07c325d1f49e4b722f76aa730ac5d084bd0e77a (diff) | |
| download | emacs-6735df4443fe0aa60862a95c38746edf2b053862.tar.gz emacs-6735df4443fe0aa60862a95c38746edf2b053862.zip | |
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.
| -rw-r--r-- | lisp/electric.el | 1 | ||||
| -rw-r--r-- | test/lisp/electric-tests.el | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lisp/electric.el b/lisp/electric.el index 8343d8c1b13..c00e7c00a59 100644 --- a/lisp/electric.el +++ b/lisp/electric.el | |||
| @@ -505,6 +505,7 @@ This requotes when a quoting key is typed." | |||
| 505 | (eq last-command-event ?\"))) | 505 | (eq last-command-event ?\"))) |
| 506 | (save-excursion | 506 | (save-excursion |
| 507 | (backward-char) | 507 | (backward-char) |
| 508 | (skip-syntax-backward "\\") | ||
| 508 | (or (bobp) (bolp) | 509 | (or (bobp) (bolp) |
| 509 | (memq (char-before) (list q< q<<)) | 510 | (memq (char-before) (list q< q<<)) |
| 510 | (memq (char-syntax (char-before)) | 511 | (memq (char-syntax (char-before)) |
diff --git a/test/lisp/electric-tests.el b/test/lisp/electric-tests.el index 44bdbc7b8c8..60191bfbbaa 100644 --- a/test/lisp/electric-tests.el +++ b/test/lisp/electric-tests.el | |||
| @@ -742,6 +742,24 @@ baz\"\"" | |||
| 742 | :bindings '((electric-quote-replace-double . t)) | 742 | :bindings '((electric-quote-replace-double . t)) |
| 743 | :test-in-comments nil :test-in-strings nil) | 743 | :test-in-comments nil :test-in-strings nil) |
| 744 | 744 | ||
| 745 | (define-electric-pair-test electric-quote-replace-double-escaped-open | ||
| 746 | "foo \\" "-----\"" :expected-string "foo \\“" | ||
| 747 | :expected-point 7 :modes '(emacs-lisp-mode c-mode) | ||
| 748 | :fixture-fn #'electric-quote-local-mode | ||
| 749 | :bindings '((electric-quote-replace-double . t) | ||
| 750 | (electric-quote-comment . t) | ||
| 751 | (electric-quote-string . t)) | ||
| 752 | :test-in-comments t :test-in-strings t :test-in-code nil) | ||
| 753 | |||
| 754 | (define-electric-pair-test electric-quote-replace-double-escaped-close | ||
| 755 | "foo \\“foo\\" "----------\"" :expected-string "foo \\“foo\\”" | ||
| 756 | :expected-point 12 :modes '(emacs-lisp-mode c-mode) | ||
| 757 | :fixture-fn #'electric-quote-local-mode | ||
| 758 | :bindings '((electric-quote-replace-double . t) | ||
| 759 | (electric-quote-comment . t) | ||
| 760 | (electric-quote-string . t)) | ||
| 761 | :test-in-comments t :test-in-strings t :test-in-code nil) | ||
| 762 | |||
| 745 | ;; Simulate ‘markdown-mode’: it sets both ‘comment-start’ and | 763 | ;; Simulate ‘markdown-mode’: it sets both ‘comment-start’ and |
| 746 | ;; ‘comment-use-syntax’, but derives from ‘text-mode’. | 764 | ;; ‘comment-use-syntax’, but derives from ‘text-mode’. |
| 747 | (define-electric-pair-test electric-quote-markdown-in-text | 765 | (define-electric-pair-test electric-quote-markdown-in-text |