[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-24 r116922: Inhibit quote autopairing more frequentl
From: |
João Távora |
Subject: |
[Emacs-diffs] emacs-24 r116922: Inhibit quote autopairing more frequently |
Date: |
Mon, 07 Apr 2014 07:24:11 +0000 |
User-agent: |
Bazaar (2.6b2) |
------------------------------------------------------------
revno: 116922
revision-id: address@hidden
parent: address@hidden
committer: João Távora <address@hidden>
branch nick: emacs-24
timestamp: Mon 2014-04-07 08:24:03 +0100
message:
Inhibit quote autopairing more frequently
Backported from trunk r116926
* lisp/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.
* test/automated/electric-tests.el (inhibit-if-strings-mismatched):
New test, change from `inhibit-only-of-next-is-mismatched'.
modified:
lisp/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-1432
lisp/elec-pair.el elecpair.el-20131227124533-yaq8recs0j0ggt67-1
test/ChangeLog changelog-20091113204419-o5vbwnq5f7feedwu-8588
test/automated/electric-tests.el
electrictests.el-20131226202454-s3cqbs9maop0w8qy-1
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2014-04-07 01:27:32 +0000
+++ b/lisp/ChangeLog 2014-04-07 07:24:03 +0000
@@ -1,3 +1,11 @@
+2014-04-07 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-04-07 Glenn Morris <address@hidden>
* shell.el (shell-directory-tracker):
=== modified file 'lisp/elec-pair.el'
--- a/lisp/elec-pair.el 2014-04-06 23:37:17 +0000
+++ b/lisp/elec-pair.el 2014-04-07 07:24:03 +0000
@@ -334,18 +334,17 @@
(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)
+ "Return non-nil if inside unterminated string started by 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)
@@ -379,7 +378,9 @@
(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)
=== modified file 'test/ChangeLog'
--- a/test/ChangeLog 2014-04-06 23:23:45 +0000
+++ b/test/ChangeLog 2014-04-07 07:24:03 +0000
@@ -1,3 +1,8 @@
+2014-04-07 João Távora <address@hidden>
+
+ * automated/electric-tests.el (inhibit-if-strings-mismatched):
+ New test, change from `inhibit-only-of-next-is-mismatched'.
+
2014-04-06 João Távora <address@hidden>
* automated/python-tests.el (python-triple-quote-pairing): New test.
=== modified file 'test/automated/electric-tests.el'
--- a/test/automated/electric-tests.el 2014-04-06 23:09:19 +0000
+++ b/test/automated/electric-tests.el 2014-04-07 07:24:03 +0000
@@ -295,9 +295,9 @@
: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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs-24 r116922: Inhibit quote autopairing more frequently,
João Távora <=