|
1 | 1 | ;;; drupal/etags.el --- Drupal-mode support for etags |
2 | 2 |
|
3 | | -;; Copyright (C) 2012 Arne Jørgensen |
| 3 | +;; Copyright (C) 2012, 2013 Arne Jørgensen |
4 | 4 |
|
5 | 5 | ;; Author: Arne Jørgensen <[email protected]> |
6 | 6 |
|
|
29 | 29 | (require 'drupal/emacs-drush) |
30 | 30 |
|
31 | 31 | (defun drupal/etags-enable () |
32 | | - "Setup TAGS file for etags if it exists in DRUPAL_ROOT." |
33 | | - (when (and (boundp 'drupal-rootdir) |
34 | | - (file-exists-p (concat drupal-rootdir "TAGS"))) |
35 | | - ;; Set `tags-file-name' to the TAGS file located in |
36 | | - ;; `drupal-rootdir'. |
37 | | - (setq tags-file-name (concat drupal-rootdir "TAGS")) |
38 | | - (tags-completion-table) |
39 | | - |
40 | | - ;; Set `drupal-symbol-collection' to `tags-completion-table' so |
41 | | - ;; that inserting hooks will do completion based on etags. |
42 | | - (setq drupal-get-function-args #'drupal/etags-get-function-args) |
43 | | - (setq drupal-symbol-collection #'tags-completion-table))) |
| 32 | + "Setup TAGS file for etags if it exists." |
| 33 | + (let ((dir (locate-dominating-file (buffer-file-name) "TAGS"))) |
| 34 | + (when dir |
| 35 | + (set (make-local-variable 'drupal/etags-rootdir) dir) |
| 36 | + |
| 37 | + ;; Set `tags-file-name' to the TAGS file located in |
| 38 | + ;; `drupal-rootdir'. |
| 39 | + (setq tags-file-name (concat drupal/etags-rootdir "TAGS")) |
| 40 | + (tags-completion-table) |
| 41 | + |
| 42 | + ;; Set `drupal-symbol-collection' to `tags-completion-table' so |
| 43 | + ;; that inserting hooks will do completion based on etags. |
| 44 | + (setq drupal-get-function-args #'drupal/etags-get-function-args) |
| 45 | + (setq drupal-symbol-collection #'tags-completion-table)))) |
44 | 46 |
|
45 | 47 | (defun drupal/etags-get-function-args (symbol &optional version) |
46 | 48 | "Get function arguments from etags TAGS." |
47 | | - (when (and (boundp 'drupal-rootdir) |
48 | | - (file-exists-p (concat drupal-rootdir "TAGS"))) |
| 49 | + (when (and (boundp 'drupal/etags-rootdir) |
| 50 | + (file-exists-p (concat drupal/etags-rootdir "TAGS"))) |
49 | 51 | (with-current-buffer (find-tag-noselect symbol nil nil) |
50 | 52 | (goto-char (point-min)) |
51 | 53 | (when (re-search-forward |
|
0 commit comments