[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Emacs pretest
From: |
João Távora |
Subject: |
Re: Emacs pretest |
Date: |
Mon, 31 Mar 2014 16:55:29 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (windows-nt) |
Stefan Monnier <address@hidden> 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 <address@hidden>
+
+ * 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 <address@hidden>
* 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 <address@hidden>
+
+ * automated/electric-tests.el (inhibit-if-strings-mismatched):
+ Change from `inhibit-only-of-next-is-mismatched'.
+
2014-03-24 Barry O'Reilly <address@hidden>
* 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