]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix triple-quoting electricity in python-mode
authorJoão Távora <joaotavora@gmail.com>
Sun, 6 Apr 2014 23:23:45 +0000 (00:23 +0100)
committerJoão Távora <joaotavora@gmail.com>
Sun, 6 Apr 2014 23:23:45 +0000 (00:23 +0100)
* lisp/progmodes/python.el (python-electric-pair-string-delimiter): Fix
triple-quoting electricity.

* test/automated/python-tests.el (python-triple-quote-pairing): New test.
(python-syntax-after-python-backspace): New test.

Fixes: debbugs:17192
lisp/ChangeLog
lisp/progmodes/python.el
test/ChangeLog
test/automated/python-tests.el

index 7d6436cfafc08d3caf8b1490041492402681ef26..c30c02dcef361edf5e8fff4c31bcbab41a981846 100644 (file)
@@ -1,9 +1,14 @@
+2014-04-06  João Távora  <joaotavora@gmail.com>
+
+       * progmodes/python.el (python-electric-pair-string-delimiter): Fix
+       triple-quoting electricity.  (Bug#17192)
+
 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)
+       electric-pair--skip-whitespace.  (Bug#17183)
 
 2014-04-06  Eli Zaretskii  <eliz@gnu.org>
 
index b0102c55ffd78a1215293b32d08d30cd2e4f643b..240cf8aff8ce45f62ac1afe1f984db50e2e1bf37 100644 (file)
@@ -3651,8 +3651,9 @@ returned as is."
              (let ((count 0))
                (while (eq (char-before (- (point) count)) last-command-event)
                  (cl-incf count))
-               (= count 3)))
-    (save-excursion (insert (make-string 3 last-command-event)))))
+               (= count 3))
+             (eq (char-after) last-command-event))
+    (save-excursion (insert (make-string 2 last-command-event)))))
 
 (defvar electric-indent-inhibit)
 
index 846da9621fcc95b745b3db5bc6f62b88cbdd1bcc..d483b0b2f9e74a8163bb0f41c8a6a2bdd69b4875 100644 (file)
@@ -1,3 +1,8 @@
+2014-04-06  João Távora  <joaotavora@gmail.com>
+
+       * automated/python-tests.el (python-triple-quote-pairing): New test.
+       (python-syntax-after-python-backspace): New test.
+
 2014-04-06  João Távora  <joaotavora@gmail.com>
 
        * automated/electric-tests.el (electric-pair-define-test-form):
index dc58138ced418672ad8274f4b47185786229e6d1..8fe8f71264fa1db68ee4c50d5a1b1f40cf65495d 100644 (file)
@@ -134,6 +134,16 @@ aliqua."
 \f
 ;;; Font-lock and syntax
 
+(ert-deftest python-syntax-after-python-backspace ()
+  ;; `python-indent-dedent-line-backspace' garbles syntax
+  :expected-result :failed
+  (python-tests-with-temp-buffer
+      "\"\"\""
+    (goto-char (point-max))
+    (python-indent-dedent-line-backspace 1)
+    (should (string= (buffer-string) "\"\""))
+    (should (null (nth 3 (syntax-ppss))))))
+
 \f
 ;;; Indentation
 
@@ -2696,6 +2706,9 @@ def foo(a, b, c):
         (equal (symbol-value (car ccons)) (cdr ccons)))))
     (kill-buffer buffer)))
 
+\f
+;;; Electricity
+
 (ert-deftest python-util-forward-comment-1 ()
   (python-tests-with-temp-buffer
    (concat
@@ -2708,6 +2721,32 @@ def foo(a, b, c):
    (python-util-forward-comment -1)
    (should (= (point) (point-min)))))
 
+(ert-deftest python-triple-quote-pairing ()
+  (python-tests-with-temp-buffer
+      "\"\"\n"
+    (goto-char (1- (point-max)))
+    (let ((last-command-event ?\"))
+      (call-interactively 'self-insert-command))
+    (should (string= (buffer-string)
+                     "\"\"\"\"\"\"\n"))
+    (should (= (point) 4)))
+  (python-tests-with-temp-buffer
+      "\n"
+    (let ((last-command-event ?\"))
+      (dotimes (i 3)
+        (call-interactively 'self-insert-command)))
+    (should (string= (buffer-string)
+                     "\"\"\"\"\"\"\n"))
+    (should (= (point) 4)))
+  (python-tests-with-temp-buffer
+      "\"\n\"\"\n"
+    (goto-char (1- (point-max)))
+    (let ((last-command-event ?\"))
+      (call-interactively 'self-insert-command))
+    (should (= (point) (1- (point-max))))
+    (should (string= (buffer-string)
+                     "\"\n\"\"\"\n"))))
+
 
 (provide 'python-tests)