emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] emacs-24 r117470: * lisp/progmodes/python.el (python-inden


From: Fabián Ezequiel Gallina
Subject: [Emacs-diffs] emacs-24 r117470: * lisp/progmodes/python.el (python-indent-post-self-insert-function):
Date: Mon, 01 Sep 2014 22:52:07 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 117470
revision-id: address@hidden
parent: address@hidden
fixes bug: http://debbugs.gnu.org/18228
committer: Fabián Ezequiel Gallina <address@hidden>
branch nick: emacs-24
timestamp: Mon 2014-09-01 19:51:46 -0300
message:
  * lisp/progmodes/python.el (python-indent-post-self-insert-function):
  Avoid electric colon at beginning-of-defun. 
  
  * test/automated/python-tests.el:
  (python-indent-electric-colon-1): New test.  (Bug#18228)
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-09-01 16:44:06 +0000
+++ b/lisp/ChangeLog    2014-09-01 22:51:46 +0000
@@ -1,3 +1,8 @@
+2014-09-01  Fabián Ezequiel Gallina  <address@hidden>
+
+       * progmodes/python.el (python-indent-post-self-insert-function):
+       Avoid electric colon at beginning-of-defun.  (Bug#18228)
+
 2014-09-01  Glenn Morris  <address@hidden>
 
        * tutorial.el (tutorial--display-changes):

=== modified file 'lisp/progmodes/python.el'
--- a/lisp/progmodes/python.el  2014-08-18 16:11:43 +0000
+++ b/lisp/progmodes/python.el  2014-09-01 22:51:46 +0000
@@ -1155,9 +1155,15 @@
      ((and (eq ?: last-command-event)
            (memq ?: electric-indent-chars)
            (not current-prefix-arg)
+           ;; Trigger electric colon only at end of line
            (eolp)
+           ;; Avoid re-indenting on extra colon
            (not (equal ?: (char-before (1- (point)))))
-           (not (python-syntax-comment-or-string-p)))
+           (not (python-syntax-comment-or-string-p))
+           ;; Never re-indent at beginning of defun
+           (not (save-excursion
+                  (python-nav-beginning-of-statement)
+                  (python-info-looking-at-beginning-of-defun))))
       (python-indent-line)))))
 
 

=== modified file 'test/ChangeLog'
--- a/test/ChangeLog    2014-08-18 19:15:06 +0000
+++ b/test/ChangeLog    2014-09-01 22:51:46 +0000
@@ -1,3 +1,8 @@
+2014-09-01  Fabián Ezequiel Gallina  <address@hidden>
+
+       * automated/python-tests.el:
+       (python-indent-electric-colon-1): New test.  (Bug#18228)
+
 2014-08-18  Glenn Morris  <address@hidden>
 
        * automated/python-tests.el (python-shell-calculate-exec-path-2):

=== modified file 'test/automated/python-tests.el'
--- a/test/automated/python-tests.el    2014-08-18 19:15:06 +0000
+++ b/test/automated/python-tests.el    2014-09-01 22:51:46 +0000
@@ -711,6 +711,20 @@
     (should (= (python-indent-calculate-indentation) 0))
     (should (equal (python-indent-calculate-levels) '(0)))))
 
+(ert-deftest python-indent-electric-colon-1 ()
+  "Test indentation case from Bug#18228."
+  (python-tests-with-temp-buffer
+   "
+def a():
+    pass
+
+def b()
+"
+   (python-tests-look-at "def b()")
+   (goto-char (line-end-position))
+   (python-tests-self-insert ":")
+   (should (= (current-indentation) 0))))
+
 
 ;;; Navigation
 


reply via email to

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