I've hacked together a few things for utilising TAGS files, which I'd be happy to contribute (although it's probably a bit specific to my config at present, so I'll have to separate it out).
The main feature is a function which generates a template hook implementation. You pass it the hook name (e.g. "hook_menu") and it looks that up in the TAGS file (e.g. in modules/system/system.api.php for Drupal 7; for Drupal 6 you need to download the developer docs separately), grabs the body of that definition, and inserts it into the module you are editing (with the standard header comments, and the correct function name based on the module you are editing).
It's not pretty, but it works correctly in the majority of cases.
I also regenerate the TAGS file regularly from Emacs using a timer. I keep meaning to look into GNU Global which should be a better solution, but have never gotten around to that, as my present approach works well enough.
If it sounds useful, I'll tidy it up a bit when I have some time (some code would definitely need to be made more general), and post it here.
Comments
Comment #1
axel commentedYet I prepared some templates with Yasnippet, but really will useful a way of autogeneration of hooks. Your method looks interesting. I'll wait your code contribution as a patch or just an archive.
Formerly I used my python script for regenerating TAGS on files changes (with inotify), but now I just regenerate TAGS manually. Both methods not the way for Emacs than I don't plan to include a work with tags to the project releases until good solution coming. Thank you for pointing to GNU Global, I don't used it before.
Comment #2
jweowu commentedI'm making some changes to the other code, but the hook template function isn't affected by any of that, so I'll provide that as-is:
Comment #3
axel commentedFunction works OK in my Emacs. Thank you for this contribution! I'll include it to the nearest release. Thought method of TAGS generation still not clear. I tried GNU global 6.2 on Drupal 7 sources and got error "input buffer overflow, can't enlarge buffer because scanner uses REJECT" on system.api.php. Seems like the file is too large for a lexer. I don't found workaround for it (only exclude the file from scanning process). In principle we may include pregenerated TAGS file as hooks list not changed until new Drupal release.
Comment #4
axel commentedFunction adapted for drupal-mode as `drupal-hook-template-insert` (commit #5a6e881). Original contributed function placed as is to `extras/drupal-insert-hook.el` (commit #b42c268).
Comment #5
axel commentedComment #6
arnested commentedWhile creating "Drush utilities for Emacs users" I digged a bit into it, see http://comments.gmane.org/gmane.comp.gnu.global.bugs/1439.
Hopefully it will be fixed in an upcoming version of GNU GLOBAL (and then I'll update "Drush utilities for Emacs users").
Comment #7
axel commentedarnested, thank you for information. I'll try next integration effort of GNU Global. New issue http://drupal.org/node/1634096 created.