From: joaotavora@gmail.com (João Távora)
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: Sean Sieger <sean.sieger@gmail.com>, emacs-devel@gnu.org
Subject: Re: Emacs pretest
Date: Mon, 31 Mar 2014 16:55:29 +0100 [thread overview]
Message-ID: <jjbmwg6e51q.fsf@gmail.com> (raw)
In-Reply-To: <jwvsipyts6k.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Mon, 31 Mar 2014 09:27:30 -0400")
Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
> I think we're ready for the first pretest. Sean, can you take care of
> it?
I'd like to commit a minor functional change to lisp/elec-pair.el. I've
been holding on to it for lazyness. Is it too late?
João
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 747bbcf..aa08b90 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
+2014-03-31 João Távora <joaotavora@gmail.com>
+
+ * elec-pair.el (electric-pair-inhibit-if-helps-balance): Inhibit
+ quote pairing if `point-max' is inside an unterminated string.
+ (electric-pair--looking-at-unterminated-string-p):
+ Delete.
+ (electric-pair--in-unterminated-string-p): New function.
+
2014-03-29 Juri Linkov <juri@jurta.org>
* dired-aux.el (dired-compress-file): Don't use string-match-p
diff --git a/lisp/elec-pair.el b/lisp/elec-pair.el
index 52ad9bc..77d4bd2 100644
--- a/lisp/elec-pair.el
+++ b/lisp/elec-pair.el
@@ -364,18 +364,17 @@ If point is not enclosed by any lists, return ((t) . (t))."
(funcall ended-prematurely-fn)))))))
(cons innermost outermost)))
-(defun electric-pair--looking-at-unterminated-string-p (char)
- "Return non-nil if following string starts with CHAR and is unterminated."
- ;; FIXME: ugly/naive
- (save-excursion
- (skip-chars-forward (format "^%c" char))
- (while (not (zerop (% (save-excursion (skip-syntax-backward "\\")) 2)))
- (unless (eobp)
- (forward-char 1)
- (skip-chars-forward (format "^%c" char))))
- (and (not (eobp))
- (condition-case nil
- (progn (forward-sexp) nil)
+(defun electric-pair--in-unterminated-string-p (char)
+ "Say if inside an unterminated string started with CHAR"
+ (let* ((ppss (syntax-ppss))
+ (relevant-ppss (if (nth 4 ppss) ; in comment
+ (electric-pair--syntax-ppss)
+ ppss))
+ (string-delim (nth 3 relevant-ppss)))
+ (and (or (eq t string-delim)
+ (eq char string-delim))
+ (condition-case nil (progn (scan-sexps (nth 8 relevant-ppss) 1)
+ nil)
(scan-error t)))))
(defun electric-pair--inside-string-p (char)
@@ -409,7 +408,9 @@ happened."
(t
(eq (cdr outermost) pair)))))
((eq syntax ?\")
- (electric-pair--looking-at-unterminated-string-p char))))
+ (save-excursion
+ (goto-char (point-max))
+ (electric-pair--in-unterminated-string-p char)))))
(insert-char char)))))
(defun electric-pair-skip-if-helps-balance (char)
diff --git a/test/ChangeLog b/test/ChangeLog
index 5e5a8ae..1d3fb7b 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2014-03-31 João Távora <joaotavora@gmail.com>
+
+ * automated/electric-tests.el (inhibit-if-strings-mismatched):
+ Change from `inhibit-only-of-next-is-mismatched'.
+
2014-03-24 Barry O'Reilly <gundaetiapo@gmail.com>
* automated/undo-tests.el (undo-test-marker-adjustment-nominal):
diff --git a/test/automated/electric-tests.el b/test/automated/electric-tests.el
index e3ffd1a..c43b87f 100644
--- a/test/automated/electric-tests.el
+++ b/test/automated/electric-tests.el
@@ -295,9 +295,9 @@ Should %s \"%s\" and point at %d"
:bindings `((electric-pair-text-syntax-table
. ,prog-mode-syntax-table)))
-(define-electric-pair-test inhibit-only-if-next-is-mismatched
+(define-electric-pair-test inhibit-if-strings-mismatched
"\"foo\"\"bar" "\""
- :expected-string "\"\"\"foo\"\"bar"
+ :expected-string "\"\"foo\"\"bar"
:expected-point 2
:test-in-strings nil
:bindings `((electric-pair-text-syntax-table
next prev parent reply other threads:[~2014-03-31 15:55 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CADWZ7fJCws0SO1hEn38CpbRMq+Uw397uCFUnA=YJvOaLVEA8UQ@mail.gmail.com>
2014-03-31 13:27 ` Emacs pretest Stefan Monnier
2014-03-31 13:52 ` Bastien
2014-03-31 14:36 ` Tassilo Horn
2014-03-31 15:55 ` João Távora [this message]
2014-03-31 16:34 ` Stefan Monnier
2014-04-02 10:11 ` Emacs pretest -- electric-pair-mode change João Távora
2014-04-02 12:58 ` Stefan Monnier
2014-04-02 17:21 ` João Távora
2014-04-02 22:58 ` Stefan Monnier
2014-04-03 11:06 ` João Távora
2014-04-03 14:22 ` Stefan Monnier
2014-04-03 16:56 ` João Távora
2014-04-03 17:33 ` Stefan Monnier
2014-04-03 20:11 ` João Távora
2014-04-03 20:54 ` Stefan Monnier
2014-04-04 8:08 ` João Távora
2014-04-04 12:53 ` Stefan Monnier
2014-04-04 23:31 ` João Távora
2014-04-05 15:29 ` Stefan Monnier
2014-04-07 7:43 ` João Távora
2014-04-07 14:04 ` Stefan Monnier
2014-04-04 7:53 ` Eli Zaretskii
2014-04-04 9:49 ` João Távora
2014-04-11 14:42 ` Kevin Rodgers
2014-04-11 15:53 ` Stefan Monnier
2014-04-11 18:23 ` João Távora
2014-04-11 19:58 ` Stefan Monnier
2014-04-12 0:42 ` João Távora
2014-04-11 16:08 ` João Távora
2014-04-03 19:13 ` Eli Zaretskii
2014-04-03 12:15 ` Dmitry Gutov
2014-04-03 13:43 ` João Távora
2014-04-03 15:24 ` Stefan Monnier
2014-04-03 14:24 ` Stefan Monnier
2014-04-01 15:15 ` Emacs pretest Dmitry Antipov
2014-04-01 16:36 ` Dmitry Antipov
2014-04-02 12:37 ` Stefan Monnier
2014-04-01 20:50 ` Stephen Berman
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=jjbmwg6e51q.fsf@gmail.com \
--to=joaotavora@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@IRO.UMontreal.CA \
--cc=sean.sieger@gmail.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.