emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] trunk r116926: Inhibit quote autopairing more frequently


From: João Távora
Subject: [Emacs-diffs] trunk r116926: Inhibit quote autopairing more frequently
Date: Wed, 02 Apr 2014 09:59:16 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 116926
revision-id: address@hidden
parent: address@hidden
committer: João Távora <address@hidden>
branch nick: trunk
timestamp: Wed 2014-04-02 10:59:06 +0100
message:
  Inhibit quote autopairing more frequently
  
  * 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-01 20:48:02 +0000
+++ b/lisp/ChangeLog    2014-04-02 09:59:06 +0000
@@ -1,3 +1,11 @@
+2014-04-02  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-01  Daniel Colascione  <address@hidden>
 
        * minibuffer.el (minibuffer-complete): Prevent assertion failure

=== modified file 'lisp/elec-pair.el'
--- a/lisp/elec-pair.el 2014-02-23 00:19:11 +0000
+++ b/lisp/elec-pair.el 2014-04-02 09:59:06 +0000
@@ -364,18 +364,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)
@@ -409,7 +408,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-03-26 15:57:13 +0000
+++ b/test/ChangeLog    2014-04-02 09:59:06 +0000
@@ -1,3 +1,8 @@
+2014-04-02  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-03-26  Barry O'Reilly  <address@hidden>
 
        * automated/undo-tests.el (undo-test-marker-adjustment-nominal):

=== modified file 'test/automated/electric-tests.el'
--- a/test/automated/electric-tests.el  2014-01-01 07:43:34 +0000
+++ b/test/automated/electric-tests.el  2014-04-02 09:59:06 +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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]