aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorBill Wohler2013-03-02 14:55:12 -0800
committerBill Wohler2013-03-02 14:55:12 -0800
commitaef2281c76c1a6ec9cb988b8c339a1ed569f1114 (patch)
treeee1503fffe75c38cc306ad85ca594a5ee2ee27dc /lisp/progmodes/python.el
parent21733e4f154f8830fa568a347a0d6dbd59793c2b (diff)
parent2db41375423b6a48a55df2c5922bb2813319f06f (diff)
downloademacs-aef2281c76c1a6ec9cb988b8c339a1ed569f1114.tar.gz
emacs-aef2281c76c1a6ec9cb988b8c339a1ed569f1114.zip
Merge from trunk; up to 2013-03-02T21:05:52Z!eggert@cs.ucla.edu.
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el90
1 files changed, 45 insertions, 45 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index eadb06fa61e..f0f67d01845 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -708,10 +708,9 @@ START is the buffer position where the sexp starts."
708 ;; After backslash 708 ;; After backslash
709 ((setq start (when (not (or (python-syntax-context 'string ppss) 709 ((setq start (when (not (or (python-syntax-context 'string ppss)
710 (python-syntax-context 'comment ppss))) 710 (python-syntax-context 'comment ppss)))
711 (let ((line-beg-pos (line-beginning-position))) 711 (let ((line-beg-pos (line-number-at-pos)))
712 (when (python-info-line-ends-backslash-p 712 (python-info-line-ends-backslash-p
713 (1- line-beg-pos)) 713 (1- line-beg-pos)))))
714 (- line-beg-pos 2)))))
715 'after-backslash) 714 'after-backslash)
716 ;; After beginning of block 715 ;; After beginning of block
717 ((setq start (save-excursion 716 ((setq start (save-excursion
@@ -2960,39 +2959,40 @@ not inside a defun."
2960 (type)) 2959 (type))
2961 (catch 'exit 2960 (catch 'exit
2962 (while (python-nav-beginning-of-defun 1) 2961 (while (python-nav-beginning-of-defun 1)
2963 (when (and 2962 (when (save-match-data
2964 (or (not last-indent) 2963 (and
2965 (< (current-indentation) last-indent)) 2964 (or (not last-indent)
2966 (or 2965 (< (current-indentation) last-indent))
2967 (and first-run 2966 (or
2967 (and first-run
2968 (save-excursion
2969 ;; If this is the first run, we may add
2970 ;; the current defun at point.
2971 (setq first-run nil)
2972 (goto-char starting-pos)
2973 (python-nav-beginning-of-statement)
2974 (beginning-of-line 1)
2975 (looking-at-p
2976 python-nav-beginning-of-defun-regexp)))
2977 (< starting-pos
2968 (save-excursion 2978 (save-excursion
2969 ;; If this is the first run, we may add 2979 (let ((min-indent
2970 ;; the current defun at point. 2980 (+ (current-indentation)
2971 (setq first-run nil) 2981 python-indent-offset)))
2972 (goto-char starting-pos) 2982 (if (< starting-indentation min-indent)
2973 (python-nav-beginning-of-statement) 2983 ;; If the starting indentation is not
2974 (beginning-of-line 1) 2984 ;; within the min defun indent make the
2975 (looking-at-p 2985 ;; check fail.
2976 python-nav-beginning-of-defun-regexp))) 2986 starting-pos
2977 (< starting-pos 2987 ;; Else go to the end of defun and add
2978 (save-excursion 2988 ;; up the current indentation to the
2979 (let ((min-indent 2989 ;; ending position.
2980 (+ (current-indentation) 2990 (python-nav-end-of-defun)
2981 python-indent-offset))) 2991 (+ (point)
2982 (if (< starting-indentation min-indent) 2992 (if (>= (current-indentation) min-indent)
2983 ;; If the starting indentation is not 2993 (1+ (current-indentation))
2984 ;; within the min defun indent make the 2994 0)))))))))
2985 ;; check fail. 2995 (save-match-data (setq last-indent (current-indentation)))
2986 starting-pos
2987 ;; Else go to the end of defun and add
2988 ;; up the current indentation to the
2989 ;; ending position.
2990 (python-nav-end-of-defun)
2991 (+ (point)
2992 (if (>= (current-indentation) min-indent)
2993 (1+ (current-indentation))
2994 0))))))))
2995 (setq last-indent (current-indentation))
2996 (if (or (not include-type) type) 2996 (if (or (not include-type) type)
2997 (setq names (cons (match-string-no-properties 1) names)) 2997 (setq names (cons (match-string-no-properties 1) names))
2998 (let ((match (split-string (match-string-no-properties 0)))) 2998 (let ((match (split-string (match-string-no-properties 0))))
@@ -3115,7 +3115,7 @@ With optional argument LINE-NUMBER, check that line instead."
3115 (save-restriction 3115 (save-restriction
3116 (widen) 3116 (widen)
3117 (when line-number 3117 (when line-number
3118 (goto-char line-number)) 3118 (python-util-goto-line line-number))
3119 (while (and (not (eobp)) 3119 (while (and (not (eobp))
3120 (goto-char (line-end-position)) 3120 (goto-char (line-end-position))
3121 (python-syntax-context 'paren) 3121 (python-syntax-context 'paren)
@@ -3131,7 +3131,7 @@ Optional argument LINE-NUMBER forces the line number to check against."
3131 (save-restriction 3131 (save-restriction
3132 (widen) 3132 (widen)
3133 (when line-number 3133 (when line-number
3134 (goto-char line-number)) 3134 (python-util-goto-line line-number))
3135 (when (python-info-line-ends-backslash-p) 3135 (when (python-info-line-ends-backslash-p)
3136 (while (save-excursion 3136 (while (save-excursion
3137 (goto-char (line-beginning-position)) 3137 (goto-char (line-beginning-position))
@@ -3210,7 +3210,9 @@ operator."
3210 3210
3211(defun python-info-current-line-comment-p () 3211(defun python-info-current-line-comment-p ()
3212 "Check if current line is a comment line." 3212 "Check if current line is a comment line."
3213 (char-equal (or (char-after (+ (point) (current-indentation))) ?_) ?#)) 3213 (char-equal
3214 (or (char-after (+ (line-beginning-position) (current-indentation))) ?_)
3215 ?#))
3214 3216
3215(defun python-info-current-line-empty-p () 3217(defun python-info-current-line-empty-p ()
3216 "Check if current line is empty, ignoring whitespace." 3218 "Check if current line is empty, ignoring whitespace."
@@ -3225,12 +3227,10 @@ operator."
3225 3227
3226;;; Utility functions 3228;;; Utility functions
3227 3229
3228(defun python-util-position (item seq) 3230(defun python-util-goto-line (line-number)
3229 "Find the first occurrence of ITEM in SEQ. 3231 "Move point to LINE-NUMBER."
3230Return the index of the matching item, or nil if not found." 3232 (goto-char (point-min))
3231 (let ((member-result (member item seq))) 3233 (forward-line (1- line-number)))
3232 (when member-result
3233 (- (length seq) (length member-result)))))
3234 3234
3235;; Stolen from org-mode 3235;; Stolen from org-mode
3236(defun python-util-clone-local-variables (from-buffer &optional regexp) 3236(defun python-util-clone-local-variables (from-buffer &optional regexp)