* 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.
This commit is contained in:
Fabián Ezequiel Gallina 2013-02-19 00:18:32 -03:00
parent 6db17b0200
commit 2af3b9c16e
2 changed files with 24 additions and 13 deletions

View file

@ -1,3 +1,15 @@
2013-02-19 Fabián Ezequiel Gallina <fgallina@cuca>
* 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.
2013-02-18 Michael Albinus <michael.albinus@gmx.de> 2013-02-18 Michael Albinus <michael.albinus@gmx.de>
* eshell/em-unix.el (eshell/su): Require tramp. * eshell/em-unix.el (eshell/su): Require tramp.

View file

@ -698,10 +698,9 @@ START is the buffer position where the sexp starts."
;; After backslash ;; After backslash
((setq start (when (not (or (python-syntax-context 'string ppss) ((setq start (when (not (or (python-syntax-context 'string ppss)
(python-syntax-context 'comment ppss))) (python-syntax-context 'comment ppss)))
(let ((line-beg-pos (line-beginning-position))) (let ((line-beg-pos (line-number-at-pos)))
(when (python-info-line-ends-backslash-p (python-info-line-ends-backslash-p
(1- line-beg-pos)) (1- line-beg-pos)))))
(- line-beg-pos 2)))))
'after-backslash) 'after-backslash)
;; After beginning of block ;; After beginning of block
((setq start (save-excursion ((setq start (save-excursion
@ -3105,7 +3104,7 @@ With optional argument LINE-NUMBER, check that line instead."
(save-restriction (save-restriction
(widen) (widen)
(when line-number (when line-number
(goto-char line-number)) (python-util-goto-line line-number))
(while (and (not (eobp)) (while (and (not (eobp))
(goto-char (line-end-position)) (goto-char (line-end-position))
(python-syntax-context 'paren) (python-syntax-context 'paren)
@ -3121,7 +3120,7 @@ Optional argument LINE-NUMBER forces the line number to check against."
(save-restriction (save-restriction
(widen) (widen)
(when line-number (when line-number
(goto-char line-number)) (python-util-goto-line line-number))
(when (python-info-line-ends-backslash-p) (when (python-info-line-ends-backslash-p)
(while (save-excursion (while (save-excursion
(goto-char (line-beginning-position)) (goto-char (line-beginning-position))
@ -3200,7 +3199,9 @@ operator."
(defun python-info-current-line-comment-p () (defun python-info-current-line-comment-p ()
"Check if current line is a comment line." "Check if current line is a comment line."
(char-equal (or (char-after (+ (point) (current-indentation))) ?_) ?#)) (char-equal
(or (char-after (+ (line-beginning-position) (current-indentation))) ?_)
?#))
(defun python-info-current-line-empty-p () (defun python-info-current-line-empty-p ()
"Check if current line is empty, ignoring whitespace." "Check if current line is empty, ignoring whitespace."
@ -3215,12 +3216,10 @@ operator."
;;; Utility functions ;;; Utility functions
(defun python-util-position (item seq) (defun python-util-goto-line (line-number)
"Find the first occurrence of ITEM in SEQ. "Move point to LINE-NUMBER."
Return the index of the matching item, or nil if not found." (goto-char (point-min))
(let ((member-result (member item seq))) (forward-line (1- line-number)))
(when member-result
(- (length seq) (length member-result)))))
;; Stolen from org-mode ;; Stolen from org-mode
(defun python-util-clone-local-variables (from-buffer &optional regexp) (defun python-util-clone-local-variables (from-buffer &optional regexp)