[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/emacs-24 r111259: * progmodes/python.el (py
From: |
Fabián Ezequiel Gallina |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/emacs-24 r111259: * progmodes/python.el (python-info-current-defun): Fix current |
Date: |
Wed, 13 Feb 2013 20:07:59 -0300 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 111259
fixes bug: http://debbugs.gnu.org/13618
committer: Fabián Ezequiel Gallina <address@hidden>
branch nick: emacs-24
timestamp: Wed 2013-02-13 20:07:59 -0300
message:
* progmodes/python.el (python-info-current-defun): Fix current
defun detection.
modified:
lisp/progmodes/python.el
=== modified file 'lisp/progmodes/python.el'
--- a/lisp/progmodes/python.el 2013-01-30 15:02:58 +0000
+++ b/lisp/progmodes/python.el 2013-02-13 23:07:59 +0000
@@ -2936,40 +2936,61 @@
This function is compatible to be used as
`add-log-current-defun-function' since it returns nil if point is
not inside a defun."
- (save-restriction
- (widen)
- (save-excursion
- (end-of-line 1)
- (let ((names)
- (starting-indentation
- (save-excursion
- (and
- (python-nav-beginning-of-defun 1)
- ;; This extra number is just for checking code
- ;; against indentation to work well on first run.
- (+ (current-indentation) 4))))
- (starting-point (point)))
- ;; Check point is inside a defun.
- (when (and starting-indentation
- (< starting-point
+ (save-restriction
+ (widen)
+ (save-excursion
+ (end-of-line 1)
+ (let ((names)
+ (starting-indentation (current-indentation))
+ (starting-pos (point))
+ (first-run t)
+ (last-indent)
+ (type))
+ (catch 'exit
+ (while (python-nav-beginning-of-defun 1)
+ (when (and
+ (or (not last-indent)
+ (< (current-indentation) last-indent))
+ (or
+ (and first-run
(save-excursion
- (python-nav-end-of-defun)
- (point))))
- (catch 'exit
- (while (python-nav-beginning-of-defun 1)
- (when (< (current-indentation) starting-indentation)
- (setq starting-indentation (current-indentation))
- (setq names
- (cons
- (if (not include-type)
- (match-string-no-properties 1)
- (mapconcat 'identity
- (split-string
- (match-string-no-properties 0)) " "))
- names)))
- (and (= (current-indentation) 0) (throw 'exit t)))))
- (and names
- (mapconcat (lambda (string) string) names "."))))))
+ ;; 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))
+ (if (or (not include-type) type)
+ (setq names (cons (match-string-no-properties 1) names))
+ (let ((match (split-string (match-string-no-properties 0))))
+ (setq type (car match))
+ (setq names (cons (cadr match) names)))))
+ ;; Stop searching ASAP.
+ (and (= (current-indentation) 0) (throw 'exit t))))
+ (and names
+ (concat (and type (format "%s " type))
+ (mapconcat 'identity names ".")))))))
(defun python-info-current-symbol (&optional replace-self)
"Return current symbol using dotty syntax.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/emacs-24 r111259: * progmodes/python.el (python-info-current-defun): Fix current,
Fabián Ezequiel Gallina <=