aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/progmodes/python.el
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina2013-02-19 00:18:32 -0300
committerFabián Ezequiel Gallina2013-02-19 00:18:32 -0300
commit2af3b9c16e340ad034e57e949f09bbafc00bd52c (patch)
treea8f68cb43ad0913f4c10b527276e2901eaaea0ff /lisp/progmodes/python.el
parent6db17b0200e342dae7a1e09df7f03f80dcbf3fad (diff)
downloademacs-2af3b9c16e340ad034e57e949f09bbafc00bd52c.tar.gz
emacs-2af3b9c16e340ad034e57e949f09bbafc00bd52c.zip
* progmodes/python.el (python-indent-context): Fix
python-info-line-ends-backslash-p call. (python-info-line-ends-backslash-p) (python-info-beginning-of-backslash): Respect line-number argument. (python-info-current-line-comment-p): Fix behavior when not at beginning-of-line. (python-util-position): Remove function. (python-util-goto-line): New function.
Diffstat (limited to 'lisp/progmodes/python.el')
-rw-r--r--lisp/progmodes/python.el25
1 files changed, 12 insertions, 13 deletions
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index 92f86ce1231..49eaff637a6 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -698,10 +698,9 @@ START is the buffer position where the sexp starts."
698 ;; After backslash 698 ;; After backslash
699 ((setq start (when (not (or (python-syntax-context 'string ppss) 699 ((setq start (when (not (or (python-syntax-context 'string ppss)
700 (python-syntax-context 'comment ppss))) 700 (python-syntax-context 'comment ppss)))
701 (let ((line-beg-pos (line-beginning-position))) 701 (let ((line-beg-pos (line-number-at-pos)))
702 (when (python-info-line-ends-backslash-p 702 (python-info-line-ends-backslash-p
703 (1- line-beg-pos)) 703 (1- line-beg-pos)))))
704 (- line-beg-pos 2)))))
705 'after-backslash) 704 'after-backslash)
706 ;; After beginning of block 705 ;; After beginning of block
707 ((setq start (save-excursion 706 ((setq start (save-excursion
@@ -3105,7 +3104,7 @@ With optional argument LINE-NUMBER, check that line instead."
3105 (save-restriction 3104 (save-restriction
3106 (widen) 3105 (widen)
3107 (when line-number 3106 (when line-number
3108 (goto-char line-number)) 3107 (python-util-goto-line line-number))
3109 (while (and (not (eobp)) 3108 (while (and (not (eobp))
3110 (goto-char (line-end-position)) 3109 (goto-char (line-end-position))
3111 (python-syntax-context 'paren) 3110 (python-syntax-context 'paren)
@@ -3121,7 +3120,7 @@ Optional argument LINE-NUMBER forces the line number to check against."
3121 (save-restriction 3120 (save-restriction
3122 (widen) 3121 (widen)
3123 (when line-number 3122 (when line-number
3124 (goto-char line-number)) 3123 (python-util-goto-line line-number))
3125 (when (python-info-line-ends-backslash-p) 3124 (when (python-info-line-ends-backslash-p)
3126 (while (save-excursion 3125 (while (save-excursion
3127 (goto-char (line-beginning-position)) 3126 (goto-char (line-beginning-position))
@@ -3200,7 +3199,9 @@ operator."
3200 3199
3201(defun python-info-current-line-comment-p () 3200(defun python-info-current-line-comment-p ()
3202 "Check if current line is a comment line." 3201 "Check if current line is a comment line."
3203 (char-equal (or (char-after (+ (point) (current-indentation))) ?_) ?#)) 3202 (char-equal
3203 (or (char-after (+ (line-beginning-position) (current-indentation))) ?_)
3204 ?#))
3204 3205
3205(defun python-info-current-line-empty-p () 3206(defun python-info-current-line-empty-p ()
3206 "Check if current line is empty, ignoring whitespace." 3207 "Check if current line is empty, ignoring whitespace."
@@ -3215,12 +3216,10 @@ operator."
3215 3216
3216;;; Utility functions 3217;;; Utility functions
3217 3218
3218(defun python-util-position (item seq) 3219(defun python-util-goto-line (line-number)
3219 "Find the first occurrence of ITEM in SEQ. 3220 "Move point to LINE-NUMBER."
3220Return the index of the matching item, or nil if not found." 3221 (goto-char (point-min))
3221 (let ((member-result (member item seq))) 3222 (forward-line (1- line-number)))
3222 (when member-result
3223 (- (length seq) (length member-result)))))
3224 3223
3225;; Stolen from org-mode 3224;; Stolen from org-mode
3226(defun python-util-clone-local-variables (from-buffer &optional regexp) 3225(defun python-util-clone-local-variables (from-buffer &optional regexp)