aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorFabián Ezequiel Gallina2012-11-26 18:45:58 -0300
committerFabián Ezequiel Gallina2012-11-26 18:45:58 -0300
commit207cb73c182d432a00fef797428d3b79ab519287 (patch)
tree09a38a57715b5d45872debd01a85e6ee4f2797cd /lisp
parent3fa1e84d43f401876db74e14c7b72f5190fc13b0 (diff)
downloademacs-207cb73c182d432a00fef797428d3b79ab519287.tar.gz
emacs-207cb73c182d432a00fef797428d3b79ab519287.zip
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.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/progmodes/python.el36
2 files changed, 35 insertions, 9 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index e6bad793f5a..a5ce3fcd0b2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,11 @@
12012-11-26 Fabián Ezequiel Gallina <fgallina@cuca>
2
3 Fix Imenu regression.
4 * progmodes/python.el:
5 (python-nav-beginning-of-defun): Fix forward movement when
6 statement(s) separates point from defun.
7 (python-imenu-prev-index-position): New function.
8
12012-11-26 Eli Zaretskii <eliz@gnu.org> 92012-11-26 Eli Zaretskii <eliz@gnu.org>
2 10
3 * subr.el (buffer-file-type): Declare with defvar-local. Doc fix. 11 * 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 @@
33;; Implements Syntax highlighting, Indentation, Movement, Shell 33;; Implements Syntax highlighting, Indentation, Movement, Shell
34;; interaction, Shell completion, Shell virtualenv support, Pdb 34;; interaction, Shell completion, Shell virtualenv support, Pdb
35;; tracking, Symbol completion, Skeletons, FFAP, Code Check, Eldoc, 35;; tracking, Symbol completion, Skeletons, FFAP, Code Check, Eldoc,
36;; imenu. 36;; Imenu.
37 37
38;; Syntax highlighting: Fontification of code is provided and supports 38;; Syntax highlighting: Fontification of code is provided and supports
39;; python's triple quoted strings properly. 39;; python's triple quoted strings properly.
@@ -169,10 +169,12 @@
169;; might guessed you should run `python-shell-send-buffer' from time 169;; might guessed you should run `python-shell-send-buffer' from time
170;; to time to get better results too. 170;; to time to get better results too.
171 171
172;; imenu: This mode supports imenu in its most basic form, letting it 172;; Imenu: This mode supports Imenu in its most basic form, letting it
173;; build the necessary alist via `imenu-default-create-index-function' 173;; build the necessary alist via `imenu-default-create-index-function'
174;; by having set `imenu-extract-index-name-function' to 174;; by having set `imenu-extract-index-name-function' to
175;; `python-info-current-defun'. 175;; `python-info-current-defun' and
176;; `imenu-prev-index-position-function' to
177;; `python-imenu-prev-index-position'.
176 178
177;; If you used python-mode.el you probably will miss auto-indentation 179;; If you used python-mode.el you probably will miss auto-indentation
178;; when inserting newlines. To achieve the same behavior you have 180;; when inserting newlines. To achieve the same behavior you have
@@ -1087,12 +1089,12 @@ With positive ARG search backwards, else search forwards."
1087 (beg-indentation 1089 (beg-indentation
1088 (and (> arg 0) 1090 (and (> arg 0)
1089 (save-excursion 1091 (save-excursion
1090 (and (python-info-current-line-empty-p) 1092 (while (and
1091 (python-util-forward-comment -1)) 1093 (not (python-info-looking-at-beginning-of-defun))
1092 (python-nav-beginning-of-statement) 1094 (python-nav-backward-block)))
1093 (if (python-info-looking-at-beginning-of-defun) 1095 (or (and (python-info-looking-at-beginning-of-defun)
1094 (+ (current-indentation) python-indent-offset) 1096 (+ (current-indentation) python-indent-offset))
1095 (current-indentation))))) 1097 0))))
1096 (found 1098 (found
1097 (progn 1099 (progn
1098 (when (and (< arg 0) 1100 (when (and (< arg 0)
@@ -2870,6 +2872,19 @@ Interactively, prompt for symbol."
2870 "^Eldoc needs an inferior Python process running.") 2872 "^Eldoc needs an inferior Python process running.")
2871 2873
2872 2874
2875;;; Imenu
2876
2877(defun python-imenu-prev-index-position ()
2878 "Python mode's `imenu-prev-index-position-function'."
2879 (let ((found))
2880 (while (and (setq found
2881 (re-search-backward python-nav-beginning-of-defun-regexp nil t))
2882 (not (python-info-looking-at-beginning-of-defun))))
2883 (and found
2884 (python-info-looking-at-beginning-of-defun)
2885 (python-info-current-defun))))
2886
2887
2873;;; Misc helpers 2888;;; Misc helpers
2874 2889
2875(defun python-info-current-defun (&optional include-type) 2890(defun python-info-current-defun (&optional include-type)
@@ -3214,6 +3229,9 @@ if that value is non-nil."
3214 (set (make-local-variable 'imenu-extract-index-name-function) 3229 (set (make-local-variable 'imenu-extract-index-name-function)
3215 #'python-info-current-defun) 3230 #'python-info-current-defun)
3216 3231
3232 (set (make-local-variable 'imenu-prev-index-position-function)
3233 #'python-imenu-prev-index-position)
3234
3217 (set (make-local-variable 'add-log-current-defun-function) 3235 (set (make-local-variable 'add-log-current-defun-function)
3218 #'python-info-current-defun) 3236 #'python-info-current-defun)
3219 3237