diff options
| author | João Távora | 2014-04-07 00:23:45 +0100 |
|---|---|---|
| committer | João Távora | 2014-04-07 00:23:45 +0100 |
| commit | 7aecc2f6ca3842395436f111449dbdcdce494ad5 (patch) | |
| tree | c78d04a004e0e1185e78fb4fbe36f4729d8641e8 | |
| parent | 89f20f76d8fa700d2a534834bf178ac8796d35cf (diff) | |
| download | emacs-7aecc2f6ca3842395436f111449dbdcdce494ad5.tar.gz emacs-7aecc2f6ca3842395436f111449dbdcdce494ad5.zip | |
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.
Fixes: debbugs:17192
| -rw-r--r-- | lisp/ChangeLog | 7 | ||||
| -rw-r--r-- | lisp/progmodes/python.el | 5 | ||||
| -rw-r--r-- | test/ChangeLog | 5 | ||||
| -rw-r--r-- | test/automated/python-tests.el | 39 |
4 files changed, 53 insertions, 3 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7d6436cfafc..c30c02dcef3 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,9 +1,14 @@ | |||
| 1 | 2014-04-06 João Távora <joaotavora@gmail.com> | 1 | 2014-04-06 João Távora <joaotavora@gmail.com> |
| 2 | 2 | ||
| 3 | * progmodes/python.el (python-electric-pair-string-delimiter): Fix | ||
| 4 | triple-quoting electricity. (Bug#17192) | ||
| 5 | |||
| 6 | 2014-04-06 João Távora <joaotavora@gmail.com> | ||
| 7 | |||
| 3 | * elec-pair.el (electric-pair-post-self-insert-function): Don't | 8 | * elec-pair.el (electric-pair-post-self-insert-function): Don't |
| 4 | skip whitespace when `electric-pair-text-pairs' and | 9 | skip whitespace when `electric-pair-text-pairs' and |
| 5 | `electric-pair-pairs' were used. syntax to | 10 | `electric-pair-pairs' were used. syntax to |
| 6 | electric-pair--skip-whitespace. (Bug#17183) | 11 | electric-pair--skip-whitespace. (Bug#17183) |
| 7 | 12 | ||
| 8 | 2014-04-06 Eli Zaretskii <eliz@gnu.org> | 13 | 2014-04-06 Eli Zaretskii <eliz@gnu.org> |
| 9 | 14 | ||
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index b0102c55ffd..240cf8aff8c 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el | |||
| @@ -3651,8 +3651,9 @@ returned as is." | |||
| 3651 | (let ((count 0)) | 3651 | (let ((count 0)) |
| 3652 | (while (eq (char-before (- (point) count)) last-command-event) | 3652 | (while (eq (char-before (- (point) count)) last-command-event) |
| 3653 | (cl-incf count)) | 3653 | (cl-incf count)) |
| 3654 | (= count 3))) | 3654 | (= count 3)) |
| 3655 | (save-excursion (insert (make-string 3 last-command-event))))) | 3655 | (eq (char-after) last-command-event)) |
| 3656 | (save-excursion (insert (make-string 2 last-command-event))))) | ||
| 3656 | 3657 | ||
| 3657 | (defvar electric-indent-inhibit) | 3658 | (defvar electric-indent-inhibit) |
| 3658 | 3659 | ||
diff --git a/test/ChangeLog b/test/ChangeLog index 846da9621fc..d483b0b2f9e 100644 --- a/test/ChangeLog +++ b/test/ChangeLog | |||
| @@ -1,5 +1,10 @@ | |||
| 1 | 2014-04-06 João Távora <joaotavora@gmail.com> | 1 | 2014-04-06 João Távora <joaotavora@gmail.com> |
| 2 | 2 | ||
| 3 | * automated/python-tests.el (python-triple-quote-pairing): New test. | ||
| 4 | (python-syntax-after-python-backspace): New test. | ||
| 5 | |||
| 6 | 2014-04-06 João Távora <joaotavora@gmail.com> | ||
| 7 | |||
| 3 | * automated/electric-tests.el (electric-pair-define-test-form): | 8 | * automated/electric-tests.el (electric-pair-define-test-form): |
| 4 | More readable test docstrings. | 9 | More readable test docstrings. |
| 5 | (whitespace-skipping-for-quotes-not-ouside) | 10 | (whitespace-skipping-for-quotes-not-ouside) |
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el index dc58138ced4..8fe8f71264f 100644 --- a/test/automated/python-tests.el +++ b/test/automated/python-tests.el | |||
| @@ -134,6 +134,16 @@ aliqua." | |||
| 134 | 134 | ||
| 135 | ;;; Font-lock and syntax | 135 | ;;; Font-lock and syntax |
| 136 | 136 | ||
| 137 | (ert-deftest python-syntax-after-python-backspace () | ||
| 138 | ;; `python-indent-dedent-line-backspace' garbles syntax | ||
| 139 | :expected-result :failed | ||
| 140 | (python-tests-with-temp-buffer | ||
| 141 | "\"\"\"" | ||
| 142 | (goto-char (point-max)) | ||
| 143 | (python-indent-dedent-line-backspace 1) | ||
| 144 | (should (string= (buffer-string) "\"\"")) | ||
| 145 | (should (null (nth 3 (syntax-ppss)))))) | ||
| 146 | |||
| 137 | 147 | ||
| 138 | ;;; Indentation | 148 | ;;; Indentation |
| 139 | 149 | ||
| @@ -2696,6 +2706,9 @@ def foo(a, b, c): | |||
| 2696 | (equal (symbol-value (car ccons)) (cdr ccons))))) | 2706 | (equal (symbol-value (car ccons)) (cdr ccons))))) |
| 2697 | (kill-buffer buffer))) | 2707 | (kill-buffer buffer))) |
| 2698 | 2708 | ||
| 2709 | |||
| 2710 | ;;; Electricity | ||
| 2711 | |||
| 2699 | (ert-deftest python-util-forward-comment-1 () | 2712 | (ert-deftest python-util-forward-comment-1 () |
| 2700 | (python-tests-with-temp-buffer | 2713 | (python-tests-with-temp-buffer |
| 2701 | (concat | 2714 | (concat |
| @@ -2708,6 +2721,32 @@ def foo(a, b, c): | |||
| 2708 | (python-util-forward-comment -1) | 2721 | (python-util-forward-comment -1) |
| 2709 | (should (= (point) (point-min))))) | 2722 | (should (= (point) (point-min))))) |
| 2710 | 2723 | ||
| 2724 | (ert-deftest python-triple-quote-pairing () | ||
| 2725 | (python-tests-with-temp-buffer | ||
| 2726 | "\"\"\n" | ||
| 2727 | (goto-char (1- (point-max))) | ||
| 2728 | (let ((last-command-event ?\")) | ||
| 2729 | (call-interactively 'self-insert-command)) | ||
| 2730 | (should (string= (buffer-string) | ||
| 2731 | "\"\"\"\"\"\"\n")) | ||
| 2732 | (should (= (point) 4))) | ||
| 2733 | (python-tests-with-temp-buffer | ||
| 2734 | "\n" | ||
| 2735 | (let ((last-command-event ?\")) | ||
| 2736 | (dotimes (i 3) | ||
| 2737 | (call-interactively 'self-insert-command))) | ||
| 2738 | (should (string= (buffer-string) | ||
| 2739 | "\"\"\"\"\"\"\n")) | ||
| 2740 | (should (= (point) 4))) | ||
| 2741 | (python-tests-with-temp-buffer | ||
| 2742 | "\"\n\"\"\n" | ||
| 2743 | (goto-char (1- (point-max))) | ||
| 2744 | (let ((last-command-event ?\")) | ||
| 2745 | (call-interactively 'self-insert-command)) | ||
| 2746 | (should (= (point) (1- (point-max)))) | ||
| 2747 | (should (string= (buffer-string) | ||
| 2748 | "\"\n\"\"\"\n")))) | ||
| 2749 | |||
| 2711 | 2750 | ||
| 2712 | (provide 'python-tests) | 2751 | (provide 'python-tests) |
| 2713 | 2752 | ||