GNU bug report logs - #2419
23.0.90; python-mode: Better Imenu

Previous Next

Package: emacs;

Reported by: Milan Zamazal <pdm <at> zamazal.org>

Date: Sat, 21 Feb 2009 10:30:03 UTC

Severity: wishlist

Fixed in version 24.2

Done: Fabián Ezequiel Gallina <fabian <at> anue.biz>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 2419 in the body.
You can then email your comments to 2419 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-submit-list <at> lists.donarmstrong.com, Emacs Bugs <bug-gnu-emacs <at> gnu.org>:
bug#2419; Package emacs. (Sat, 21 Feb 2009 10:30:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Milan Zamazal <pdm <at> zamazal.org>:
New bug report received and forwarded. Copy sent to Emacs Bugs <bug-gnu-emacs <at> gnu.org>. (Sat, 21 Feb 2009 10:30:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> emacsbugs.donarmstrong.com (full text, mbox):

From: Milan Zamazal <pdm <at> zamazal.org>
To: emacs-pretest-bug <at> gnu.org
Subject: 23.0.90; python-mode: Better Imenu
Date: Sat, 21 Feb 2009 11:24:23 +0100
In GNU Emacs 23.0.90.1 (x86_64-pc-linux-gnu, GTK+ Version 2.12.11)
 of 2009-02-03 on blackbird, modified by Debian
 (emacs-snapshot package, version 1:20090202-1)

The Imenu support as currently implemented in python-mode is not very
useful:

1. It is easier to use I-search than clicking through the offered
   choices.

2. When I call `M-x imenu', it usually can't find the definition of the
   identifier at the current point.

FWIW, I use the following Imenu index building function which fixes both
the problems by using single-string items, with reverse order of the
identifiers within the string.  Perhaps something like this could be
useful for other people as well.

(defun my-python-imenu-create-index ()
  (let ((index '())
        (suffix '()))
    (save-excursion
      (goto-char (point-min))
      (while (re-search-forward "^\\([ \t]*\\)\\(def\\|class\\) \\([a-zA-Z_0-9]+\\)" nil t)
        (let ((indentation (length (match-string 1)))
              (name (match-string-no-properties 3)))
          (while (and suffix (<= indentation (caar suffix)))
            (setq suffix (cdr suffix)))
          (let* ((current-suffix (if suffix (cdar suffix) ""))
                 (name+suffix (concat name current-suffix)))
            (push (cons indentation (concat "." name+suffix)) suffix)
            (push (cons name+suffix (match-end 3)) index))))
      (goto-char (point-min))
      (while (re-search-forward "^\\([a-zA-Z_0-9]+\\) *=" nil t)
        (push (cons (match-string-no-properties 1) (match-end 1)) index)))
    (sort* index 'string< :key 'car)))

Regards,

Milan Zamazal




bug reassigned from package `emacs' to `emacs,python'. Request was from Juanma Barranquero <lekktu <at> gmail.com> to control <at> emacsbugs.donarmstrong.com. (Mon, 23 Feb 2009 11:30:03 GMT) Full text and rfc822 format available.

Severity set to `wishlist' from `normal' Request was from Glenn Morris <rgm <at> gnu.org> to control <at> emacsbugs.donarmstrong.com. (Thu, 02 Apr 2009 06:55:05 GMT) Full text and rfc822 format available.

bug marked as fixed in version 24.2, send any further explanations to 2419 <at> debbugs.gnu.org and Milan Zamazal <pdm <at> zamazal.org> Request was from Fabián Ezequiel Gallina <fabian <at> anue.biz> to control <at> debbugs.gnu.org. (Tue, 17 Jul 2012 14:28:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 15 Aug 2012 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 314 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.