summaryrefslogtreecommitdiff
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2013-02-21 08:56:49 -0800
committerGlenn Morris <rgm@gnu.org>2013-02-21 08:56:49 -0800
commitcfbf790d80eaa399afceecd9a6c3e2e76bca59b0 (patch)
treeb2c7ea684fb8d24d5f51d6959aa38854e335d9b6 /lisp/progmodes/python.el
parentd20e6e9093f74ce2e435a3dac948df200e767405 (diff)
parent62cfd799f17a31188b3cdb9ffbe1421b4e6cba5d (diff)
downloademacs-cfbf790d80eaa399afceecd9a6c3e2e76bca59b0.tar.gz
Merge from emacs-24; up to 2012-12-21T07:35:02Z!ueno@gnu.org
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el65
1 files changed, 33 insertions, 32 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index da56fe70329..f0f67d01845 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2959,39 +2959,40 @@ not inside a defun."
(type))
(catch 'exit
(while (python-nav-beginning-of-defun 1)
- (when (and
- (or (not last-indent)
- (< (current-indentation) last-indent))
- (or
- (and first-run
+ (when (save-match-data
+ (and
+ (or (not last-indent)
+ (< (current-indentation) last-indent))
+ (or
+ (and first-run
+ (save-excursion
+ ;; If this is the first run, we may add
+ ;; the current defun at point.
+ (setq first-run nil)
+ (goto-char starting-pos)
+ (python-nav-beginning-of-statement)
+ (beginning-of-line 1)
+ (looking-at-p
+ python-nav-beginning-of-defun-regexp)))
+ (< starting-pos
(save-excursion
- ;; If this is the first run, we may add
- ;; the current defun at point.
- (setq first-run nil)
- (goto-char starting-pos)
- (python-nav-beginning-of-statement)
- (beginning-of-line 1)
- (looking-at-p
- python-nav-beginning-of-defun-regexp)))
- (< starting-pos
- (save-excursion
- (let ((min-indent
- (+ (current-indentation)
- python-indent-offset)))
- (if (< starting-indentation min-indent)
- ;; If the starting indentation is not
- ;; within the min defun indent make the
- ;; check fail.
- starting-pos
- ;; Else go to the end of defun and add
- ;; up the current indentation to the
- ;; ending position.
- (python-nav-end-of-defun)
- (+ (point)
- (if (>= (current-indentation) min-indent)
- (1+ (current-indentation))
- 0))))))))
- (setq last-indent (current-indentation))
+ (let ((min-indent
+ (+ (current-indentation)
+ python-indent-offset)))
+ (if (< starting-indentation min-indent)
+ ;; If the starting indentation is not
+ ;; within the min defun indent make the
+ ;; check fail.
+ starting-pos
+ ;; Else go to the end of defun and add
+ ;; up the current indentation to the
+ ;; ending position.
+ (python-nav-end-of-defun)
+ (+ (point)
+ (if (>= (current-indentation) min-indent)
+ (1+ (current-indentation))
+ 0)))))))))
+ (save-match-data (setq last-indent (current-indentation)))
(if (or (not include-type) type)
(setq names (cons (match-string-no-properties 1) names))
(let ((match (split-string (match-string-no-properties 0))))