Nested Imenu for PHP 2

Posted by Marcel M. Cary Fri, 18 Jul 2008 06:58:00 GMT

I wanted an easy way to navigate a PHP file full of object-oriented class definitions in Emacs. My search for such a tool turned up php-mode integration with imenu. Imenu allows modes to generate menus of structural elements in a file, where selecting an element jumps to to its location in the file.

But php-mode separates the list of functions from the list of classes. The list of functions is often way too long, and it's not clearly organized by class.

I wanted imenu to show functions in a class. It already supports hierarchy. So I hacked together an implementation of imenu-create-index-function that did what I wanted. Here it is: php-imenu.el

Screen Shot Menu generated for PEAR code

It's worked great on the PHP I've thrown at it, but patches are welcome to support other coding styles, etc.

Trackbacks

Use the following link to trackback from your own site:
http://www.oak.homeunix.org/~marcel/blog/trackbacks?article_id=21

Comments

Leave a comment

  1. Lennart said Mon, 21 Jul 2008 07:28:41 GMT later:
    Hi Marcel,

    I just grabbed a copy of php-imenu.el to distribute with nXhtml. Is that ok for you?

    Any suggestions for how to set it up there? Should I perhaps modify the copy of php-mode.el that I have their? (BTW did you contact the author of php-mode.el?)

  2. Marcel said Thu, 24 Jul 2008 08:01:44 GMT later:

    Lennart,

    Yes, I'd love to see php-imenu.el's functionality included with nxhtml-mode. I intend to submit a patch to php-mode, but haven't yet integrated the code in php-imenu.el with php-mode.el. Until it's integrated and released, it might be easiest to just drop php-imenu.el into your nXhtml distro along-side php-mode.el.

Comments