GNU bug report logs -
#29812
27.0.50; electric-quote-replace-double misbehaves in Lisp strings
Previous Next
Reported by: Eli Zaretskii <eliz <at> gnu.org>
Date: Fri, 22 Dec 2017 13:41:02 UTC
Severity: normal
Found in version 27.0.50
Done: Philipp Stephani <p.stephani2 <at> gmail.com>
Bug is archived. No further changes may be made.
Full log
Message #23 received at 29812 <at> debbugs.gnu.org (full text, mbox):
* 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
This bug report was last modified 7 years and 133 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.