From: Philipp Stephani <p.stephani2@gmail.com>
To: emacs-devel@gnu.org, 29812@debbugs.gnu.org
Cc: Philipp Stephani <phst@google.com>
Subject: bug#29812: [PATCH] Ignore escape characters for context-sensitive quotes (Bug#29812)
Date: Sun, 31 Dec 2017 17:51:04 +0100 [thread overview]
Message-ID: <20171231165104.68136-1-phst__36000.5086790354$1514739026$gmane$org@google.com> (raw)
In-Reply-To: <CAArVCkSTnbQnmpa=LX6TxqB9aMQdaB6jrWnej21G+g77FN9y_w@mail.gmail.com>
* 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
prev parent reply other threads:[~2017-12-31 16:51 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-22 13:40 bug#29812: 27.0.50; electric-quote-replace-double misbehaves in Lisp strings Eli Zaretskii
2017-12-30 22:07 ` Philipp Stephani
2017-12-31 15:51 ` Eli Zaretskii
2017-12-31 16:16 ` Philipp Stephani
2017-12-31 16:38 ` Eli Zaretskii
2017-12-31 16:49 ` Philipp Stephani
2017-12-31 16:59 ` Eli Zaretskii
2017-12-31 17:03 ` Philipp Stephani
2017-12-31 17:29 ` Eli Zaretskii
2018-01-07 12:56 ` Philipp Stephani
2018-01-07 16:50 ` Eli Zaretskii
2018-01-07 17:19 ` Philipp Stephani
2017-12-31 16:51 ` [PATCH] Ignore escape characters for context-sensitive quotes (Bug#29812) Philipp Stephani
2018-01-07 12:54 ` bug#29812: " Philipp Stephani
2017-12-31 16:51 ` Philipp Stephani [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='20171231165104.68136-1-phst__36000.5086790354$1514739026$gmane$org@google.com' \
--to=p.stephani2@gmail.com \
--cc=29812@debbugs.gnu.org \
--cc=emacs-devel@gnu.org \
--cc=phst@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.