]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix electric-pair-skip-whitespace with quotes in text-mode
authorJoão Távora <joaotavora@gmail.com>
Sun, 6 Apr 2014 23:09:19 +0000 (00:09 +0100)
committerJoão Távora <joaotavora@gmail.com>
Sun, 6 Apr 2014 23:09:19 +0000 (00:09 +0100)
* lisp/elec-pair.el (electric-pair-post-self-insert-function): Don't
skip whitespace for quote syntax when `electric-pair-text-pairs'
and `electric-pair-pairs' were used.

* test/automated/electric-tests.el (electric-pair-define-test-form):
More readable test docstrings.
(whitespace-skipping-for-quotes-not-ouside)
(whitespace-skipping-for-quotes-only-inside)
(whitespace-skipping-not-without-proper-syntax):

Fixes: debbugs:17183
lisp/ChangeLog
lisp/elec-pair.el
test/ChangeLog
test/automated/electric-tests.el

index b082670dc546cb4c550ee3215e0f769a5c3c3300..7d6436cfafc08d3caf8b1490041492402681ef26 100644 (file)
@@ -1,3 +1,10 @@
+2014-04-06  João Távora  <joaotavora@gmail.com>
+
+       * elec-pair.el (electric-pair-post-self-insert-function): Don't
+       skip whitespace when `electric-pair-text-pairs' and
+       `electric-pair-pairs' were used. syntax to
+       electric-pair--skip-whitespace. (Bug#17183)
+
 2014-04-06  Eli Zaretskii  <eliz@gnu.org>
 
        * leim/quail/ipa.el (ipa-x-sampa): Fix the character produced for
index 52ad9bc02493d4a4254ba763016c31bcc8c3f3ed..2c1ea7262d3422ffa2a3433169199aeb8246cf23 100644 (file)
@@ -485,10 +485,12 @@ happened."
                            (funcall electric-pair-skip-self last-command-event)
                          electric-pair-skip-self))
                    (save-excursion
-                     (when (setq skip-whitespace-info
-                                 (if (functionp electric-pair-skip-whitespace)
-                                     (funcall electric-pair-skip-whitespace)
-                                   electric-pair-skip-whitespace))
+                     (when (and (not (and unconditional
+                                          (eq syntax ?\")))
+                                (setq skip-whitespace-info
+                                      (if (functionp electric-pair-skip-whitespace)
+                                          (funcall electric-pair-skip-whitespace)
+                                        electric-pair-skip-whitespace)))
                        (electric-pair--skip-whitespace))
                      (eq (char-after) last-command-event))))
          ;; This is too late: rather than insert&delete we'd want to only
index 5e5a8ae73afdec560a996898fec134e19e97cbd6..846da9621fcc95b745b3db5bc6f62b88cbdd1bcc 100644 (file)
@@ -1,3 +1,11 @@
+2014-04-06  João Távora  <joaotavora@gmail.com>
+
+       * automated/electric-tests.el (electric-pair-define-test-form):
+       More readable test docstrings.
+       (whitespace-skipping-for-quotes-not-ouside)
+       (whitespace-skipping-for-quotes-only-inside)
+       (whitespace-skipping-for-quotes-in-text-mode): New tests.
+
 2014-03-24  Barry O'Reilly  <gundaetiapo@gmail.com>
 
        * automated/undo-tests.el (undo-test-marker-adjustment-nominal):
index e3ffd1abd2eb7a896a6da7de486de51cb7940594..184a91f5105e000fc220cd3d72d403cdce83dd10 100644 (file)
                                      mode
                                      extra-desc))
            ()
-         ,(format "With \"%s\", try input %c at point %d. \
-Should %s \"%s\" and point at %d"
+         ,(format "With |%s|, try input %c at point %d. \
+Should %s |%s| and point at %d"
                   fixture
                   char
                   (1+ pos)
@@ -341,6 +341,31 @@ Should %s \"%s\" and point at %d"
   :test-in-code nil
   :test-in-comments t)
 
+(define-electric-pair-test whitespace-skipping-for-quotes-not-ouside
+  "  \"  \"" "\"-----" :expected-string "\"\"  \"  \""
+  :expected-point 2
+  :bindings '((electric-pair-skip-whitespace . chomp))
+  :test-in-strings nil
+  :test-in-code t
+  :test-in-comments nil)
+
+(define-electric-pair-test whitespace-skipping-for-quotes-only-inside
+  "  \"  \"" "---\"--" :expected-string "  \"\""
+  :expected-point 5
+  :bindings '((electric-pair-skip-whitespace . chomp))
+  :test-in-strings nil
+  :test-in-code t
+  :test-in-comments nil)
+
+(define-electric-pair-test whitespace-skipping-quotes-not-without-proper-syntax
+  "  \"  \"" "---\"--" :expected-string "  \"\"\"  \""
+  :expected-point 5
+  :modes '(text-mode)
+  :bindings '((electric-pair-skip-whitespace . chomp))
+  :test-in-strings nil
+  :test-in-code t
+  :test-in-comments nil)
+
 \f
 ;;; Pairing arbitrary characters
 ;;;