aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina2013-02-20 17:41:46 -0300
committerFabián Ezequiel Gallina2013-02-20 17:41:46 -0300
commitc132ab7921c9d04e8054a7792b6de92fe6bc687a (patch)
treeae4b7739f98f3a4bf43fd600c900c572c82f8616 /lisp/progmodes/python.el
parent4dddd5dcda6f546f9ffb9fba2c02fd0d71ca8c07 (diff)
downloademacs-c132ab7921c9d04e8054a7792b6de92fe6bc687a.tar.gz
emacs-c132ab7921c9d04e8054a7792b6de92fe6bc687a.zip
* progmodes/python.el (python-info-current-defun): Enhance
match-data cluttering prevention.
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el68
1 files changed, 33 insertions, 35 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 1ee95daa0a9..c2739ce80a1 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -2949,42 +2949,40 @@ not inside a defun."
2949 (type)) 2949 (type))
2950 (catch 'exit 2950 (catch 'exit
2951 (while (python-nav-beginning-of-defun 1) 2951 (while (python-nav-beginning-of-defun 1)
2952 (when (and 2952 (when (save-match-data
2953 (or (not last-indent) 2953 (and
2954 (< (current-indentation) last-indent)) 2954 (or (not last-indent)
2955 (or 2955 (< (current-indentation) last-indent))
2956 (and first-run 2956 (or
2957 (and first-run
2958 (save-excursion
2959 ;; If this is the first run, we may add
2960 ;; the current defun at point.
2961 (setq first-run nil)
2962 (goto-char starting-pos)
2963 (python-nav-beginning-of-statement)
2964 (beginning-of-line 1)
2965 (looking-at-p
2966 python-nav-beginning-of-defun-regexp)))
2967 (< starting-pos
2957 (save-excursion 2968 (save-excursion
2958 ;; If this is the first run, we may add 2969 (let ((min-indent
2959 ;; the current defun at point. 2970 (+ (current-indentation)
2960 (setq first-run nil) 2971 python-indent-offset)))
2961 (goto-char starting-pos) 2972 (if (< starting-indentation min-indent)
2962 (python-nav-beginning-of-statement) 2973 ;; If the starting indentation is not
2963 (beginning-of-line 1) 2974 ;; within the min defun indent make the
2964 (looking-at-p 2975 ;; check fail.
2965 python-nav-beginning-of-defun-regexp))) 2976 starting-pos
2966 (< starting-pos 2977 ;; Else go to the end of defun and add
2967 (save-excursion 2978 ;; up the current indentation to the
2968 (let ((min-indent 2979 ;; ending position.
2969 (+ (current-indentation) 2980 (python-nav-end-of-defun)
2970 python-indent-offset))) 2981 (+ (point)
2971 (if (< starting-indentation min-indent) 2982 (if (>= (current-indentation) min-indent)
2972 ;; If the starting indentation is not 2983 (1+ (current-indentation))
2973 ;; within the min defun indent make the 2984 0)))))))))
2974 ;; check fail. 2985 (save-match-data (setq last-indent (current-indentation)))
2975 starting-pos
2976 ;; Else go to the end of defun and add
2977 ;; up the current indentation to the
2978 ;; ending position.
2979 (save-match-data
2980 ;; FIXME: avoid cluttering match-data
2981 ;; where's not wanted.
2982 (python-nav-end-of-defun))
2983 (+ (point)
2984 (if (>= (current-indentation) min-indent)
2985 (1+ (current-indentation))
2986 0))))))))
2987 (setq last-indent (current-indentation))
2988 (if (or (not include-type) type) 2986 (if (or (not include-type) type)
2989 (setq names (cons (match-string-no-properties 1) names)) 2987 (setq names (cons (match-string-no-properties 1) names))
2990 (let ((match (split-string (match-string-no-properties 0)))) 2988 (let ((match (split-string (match-string-no-properties 0))))