Fix Imenu regression.
* progmodes/python.el: (python-nav-beginning-of-defun): Fix forward movement when statement(s) separates point from defun. (python-imenu-prev-index-position): New function.
This commit is contained in:
parent
3fa1e84d43
commit
207cb73c18
2 changed files with 35 additions and 9 deletions
|
|
@ -1,3 +1,11 @@
|
|||
2012-11-26 Fabián Ezequiel Gallina <fgallina@cuca>
|
||||
|
||||
Fix Imenu regression.
|
||||
* progmodes/python.el:
|
||||
(python-nav-beginning-of-defun): Fix forward movement when
|
||||
statement(s) separates point from defun.
|
||||
(python-imenu-prev-index-position): New function.
|
||||
|
||||
2012-11-26 Eli Zaretskii <eliz@gnu.org>
|
||||
|
||||
* subr.el (buffer-file-type): Declare with defvar-local. Doc fix.
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
;; Implements Syntax highlighting, Indentation, Movement, Shell
|
||||
;; interaction, Shell completion, Shell virtualenv support, Pdb
|
||||
;; tracking, Symbol completion, Skeletons, FFAP, Code Check, Eldoc,
|
||||
;; imenu.
|
||||
;; Imenu.
|
||||
|
||||
;; Syntax highlighting: Fontification of code is provided and supports
|
||||
;; python's triple quoted strings properly.
|
||||
|
|
@ -169,10 +169,12 @@
|
|||
;; might guessed you should run `python-shell-send-buffer' from time
|
||||
;; to time to get better results too.
|
||||
|
||||
;; imenu: This mode supports imenu in its most basic form, letting it
|
||||
;; Imenu: This mode supports Imenu in its most basic form, letting it
|
||||
;; build the necessary alist via `imenu-default-create-index-function'
|
||||
;; by having set `imenu-extract-index-name-function' to
|
||||
;; `python-info-current-defun'.
|
||||
;; `python-info-current-defun' and
|
||||
;; `imenu-prev-index-position-function' to
|
||||
;; `python-imenu-prev-index-position'.
|
||||
|
||||
;; If you used python-mode.el you probably will miss auto-indentation
|
||||
;; when inserting newlines. To achieve the same behavior you have
|
||||
|
|
@ -1087,12 +1089,12 @@ With positive ARG search backwards, else search forwards."
|
|||
(beg-indentation
|
||||
(and (> arg 0)
|
||||
(save-excursion
|
||||
(and (python-info-current-line-empty-p)
|
||||
(python-util-forward-comment -1))
|
||||
(python-nav-beginning-of-statement)
|
||||
(if (python-info-looking-at-beginning-of-defun)
|
||||
(+ (current-indentation) python-indent-offset)
|
||||
(current-indentation)))))
|
||||
(while (and
|
||||
(not (python-info-looking-at-beginning-of-defun))
|
||||
(python-nav-backward-block)))
|
||||
(or (and (python-info-looking-at-beginning-of-defun)
|
||||
(+ (current-indentation) python-indent-offset))
|
||||
0))))
|
||||
(found
|
||||
(progn
|
||||
(when (and (< arg 0)
|
||||
|
|
@ -2869,6 +2871,19 @@ Interactively, prompt for symbol."
|
|||
(add-to-list 'debug-ignored-errors
|
||||
"^Eldoc needs an inferior Python process running.")
|
||||
|
||||
|
||||
;;; Imenu
|
||||
|
||||
(defun python-imenu-prev-index-position ()
|
||||
"Python mode's `imenu-prev-index-position-function'."
|
||||
(let ((found))
|
||||
(while (and (setq found
|
||||
(re-search-backward python-nav-beginning-of-defun-regexp nil t))
|
||||
(not (python-info-looking-at-beginning-of-defun))))
|
||||
(and found
|
||||
(python-info-looking-at-beginning-of-defun)
|
||||
(python-info-current-defun))))
|
||||
|
||||
|
||||
;;; Misc helpers
|
||||
|
||||
|
|
@ -3214,6 +3229,9 @@ if that value is non-nil."
|
|||
(set (make-local-variable 'imenu-extract-index-name-function)
|
||||
#'python-info-current-defun)
|
||||
|
||||
(set (make-local-variable 'imenu-prev-index-position-function)
|
||||
#'python-imenu-prev-index-position)
|
||||
|
||||
(set (make-local-variable 'add-log-current-defun-function)
|
||||
#'python-info-current-defun)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue