Nested Imenu for PHP

Posted by Marcel M. Cary Fri, 18 Jul 2008 13: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.

Posted in  | 2 comments | no trackbacks

Comments

  1. Lennart said 3 days 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 6 days 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.

Trackbacks

Use the following link to trackback from your own site:
http://www.oak.homeunix.org/~marcel/blog/trackbacks?article_id=nested-imenu-for-php&day=18&month=07&year=2008

(leave url/email »)

   Preview comment