From: Fabián Ezequiel Gallina Date: Mon, 26 Nov 2012 21:45:58 +0000 (-0300) Subject: Fix Imenu regression. X-Git-Tag: emacs-24.2.91~78 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=207cb73c182d432a00fef797428d3b79ab519287;p=emacs.git 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. --- diff --git a/lisp/ChangeLog b/lisp/ChangeLog index e6bad793f5a..a5ce3fcd0b2 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,11 @@ +2012-11-26 Fabián Ezequiel Gallina + + 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 * subr.el (buffer-file-type): Declare with defvar-local. Doc fix. diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 949b0252bf1..cfd3a73e1b0 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -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)