[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/emacs-24 r111338: Un-indent after "pass" an
From: |
Fabián Ezequiel Gallina |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/emacs-24 r111338: Un-indent after "pass" and "return" statements |
Date: |
Mon, 25 Mar 2013 22:55:11 -0300 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 111338
fixes bug: http://debbugs.gnu.org/13888
committer: Fabián Ezequiel Gallina <address@hidden>
branch nick: emacs-24
timestamp: Mon 2013-03-25 22:55:11 -0300
message:
Un-indent after "pass" and "return" statements
* lisp/progmodes/python.el (python-indent-block-enders): New var.
(python-indent-calculate-indentation): Use it.
* test/automated/python-tests.el
(python-indent-block-enders): New test.
(python-info-current-defun-2): Fix test.
modified:
lisp/ChangeLog
lisp/progmodes/python.el
test/ChangeLog
test/automated/python-tests.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2013-03-25 09:16:31 +0000
+++ b/lisp/ChangeLog 2013-03-26 01:55:11 +0000
@@ -1,3 +1,9 @@
+2013-03-26 Fabián Ezequiel Gallina <address@hidden>
+
+ Un-indent after "pass" and "return" statements (Bug#13888)
+ * progmodes/python.el (python-indent-block-enders): New var.
+ (python-indent-calculate-indentation): Use it.
+
2013-03-25 Michael Albinus <address@hidden>
* net/tramp.el (tramp-drop-volume-letter): Make it an ordinary
=== modified file 'lisp/progmodes/python.el'
--- a/lisp/progmodes/python.el 2013-02-20 20:41:46 +0000
+++ b/lisp/progmodes/python.el 2013-03-26 01:55:11 +0000
@@ -628,6 +628,12 @@
These make `python-indent-calculate-indentation' subtract the value of
`python-indent-offset'.")
+(defvar python-indent-block-enders '("return" "pass")
+ "List of words that mark the end of a block.
+These make `python-indent-calculate-indentation' subtract the
+value of `python-indent-offset' when `python-indent-context' is
+AFTER-LINE.")
+
(defun python-indent-guess-indent-offset ()
"Guess and set `python-indent-offset' for the current buffer."
(interactive)
@@ -753,9 +759,13 @@
(save-excursion
(goto-char context-start)
(current-indentation))
- (if (progn
- (back-to-indentation)
- (looking-at (regexp-opt python-indent-dedenters)))
+ (if (or (save-excursion
+ (back-to-indentation)
+ (looking-at (regexp-opt python-indent-dedenters)))
+ (save-excursion
+ (python-util-forward-comment -1)
+ (python-nav-beginning-of-statement)
+ (member (current-word) python-indent-block-enders)))
python-indent-offset
0)))
;; When inside of a string, do nothing. just use the current
=== modified file 'test/ChangeLog'
--- a/test/ChangeLog 2013-03-11 02:35:23 +0000
+++ b/test/ChangeLog 2013-03-26 01:55:11 +0000
@@ -1,3 +1,9 @@
+2013-03-26 Fabián Ezequiel Gallina <address@hidden>
+
+ * automated/python-tests.el
+ (python-indent-block-enders): New test.
+ (python-info-current-defun-2): Fix test.
+
2013-03-11 Glenn Morris <address@hidden>
* Version 24.3 released.
=== modified file 'test/automated/python-tests.el'
--- a/test/automated/python-tests.el 2013-02-25 15:02:05 +0000
+++ b/test/automated/python-tests.el 2013-03-26 01:55:11 +0000
@@ -444,6 +444,28 @@
(should (eq (car (python-indent-context)) 'after-line))
(should (= (python-indent-calculate-indentation) 0))))
+(ert-deftest python-indent-block-enders ()
+ "Test `python-indent-block-enders' value honouring."
+ (python-tests-with-temp-buffer
+ "
+Class foo(object):
+
+ def bar(self):
+ if self.baz:
+ return (1,
+ 2,
+ 3)
+
+ else:
+ pass
+"
+ (python-tests-look-at "3)")
+ (forward-line 1)
+ (= (python-indent-calculate-indentation) 12)
+ (python-tests-look-at "pass")
+ (forward-line 1)
+ (= (python-indent-calculate-indentation) 8)))
+
;;; Navigation
@@ -1546,13 +1568,13 @@
return []
def b():
- pass
+ do_b()
def a():
- pass
+ do_a()
def c(self):
- pass
+ do_c()
"
(forward-line 1)
(should (string= "C" (python-info-current-defun)))
@@ -1582,7 +1604,7 @@
(python-tests-look-at "def c(self):")
(should (string= "C.c" (python-info-current-defun)))
(should (string= "def C.c" (python-info-current-defun t)))
- (python-tests-look-at "pass")
+ (python-tests-look-at "do_c()")
(should (string= "C.c" (python-info-current-defun)))
(should (string= "def C.c" (python-info-current-defun t)))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/emacs-24 r111338: Un-indent after "pass" and "return" statements,
Fabián Ezequiel Gallina <=