emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-24 r116918: Fix triple-quoting electricity in python


From: João Távora
Subject: [Emacs-diffs] emacs-24 r116918: Fix triple-quoting electricity in python-mode
Date: Sun, 06 Apr 2014 23:23:52 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 116918
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/17192
committer: João Távora <address@hidden>
branch nick: emacs-24
timestamp: Mon 2014-04-07 00:23:45 +0100
message:
  Fix triple-quoting electricity in python-mode
  
  * 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.
modified:
  lisp/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-1432
  lisp/progmodes/python.el       python.el-20091113204419-o5vbwnq5f7feedwu-3008
  test/ChangeLog                 changelog-20091113204419-o5vbwnq5f7feedwu-8588
  test/automated/python-tests.el 
pythontests.el-20130220195218-kqcioz3fssz9hwe1-1
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2014-04-06 23:09:19 +0000
+++ b/lisp/ChangeLog    2014-04-06 23:23:45 +0000
@@ -1,9 +1,14 @@
 2014-04-06  João Távora  <address@hidden>
 
+       * progmodes/python.el (python-electric-pair-string-delimiter): Fix
+       triple-quoting electricity.  (Bug#17192)
+
+2014-04-06  João Távora  <address@hidden>
+
        * 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  <address@hidden>
 

=== modified file 'lisp/progmodes/python.el'
--- a/lisp/progmodes/python.el  2014-03-15 17:37:58 +0000
+++ b/lisp/progmodes/python.el  2014-04-06 23:23:45 +0000
@@ -3651,8 +3651,9 @@
              (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)
 

=== modified file 'test/ChangeLog'
--- a/test/ChangeLog    2014-04-06 23:09:19 +0000
+++ b/test/ChangeLog    2014-04-06 23:23:45 +0000
@@ -1,5 +1,10 @@
 2014-04-06  João Távora  <address@hidden>
 
+       * automated/python-tests.el (python-triple-quote-pairing): New test.
+       (python-syntax-after-python-backspace): New test.
+
+2014-04-06  João Távora  <address@hidden>
+
        * automated/electric-tests.el (electric-pair-define-test-form):
        More readable test docstrings.
        (whitespace-skipping-for-quotes-not-ouside)

=== modified file 'test/automated/python-tests.el'
--- a/test/automated/python-tests.el    2014-01-01 07:43:34 +0000
+++ b/test/automated/python-tests.el    2014-04-06 23:23:45 +0000
@@ -134,6 +134,16 @@
 
 ;;; 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))))))
+
 
 ;;; Indentation
 
@@ -2696,6 +2706,9 @@
         (equal (symbol-value (car ccons)) (cdr ccons)))))
     (kill-buffer buffer)))
 
+
+;;; Electricity
+
 (ert-deftest python-util-forward-comment-1 ()
   (python-tests-with-temp-buffer
    (concat
@@ -2708,6 +2721,32 @@
    (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)
 


reply via email to

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