branch: elpa/drupal-mode
commit 02eacb79f27a0c7a7eed78e9e6205b05a6f04a92
Author: Arne Jørgensen <[email protected]>
Commit: Arne Jørgensen <[email protected]>
Added `drupal/etags-get-function-args' for finding arguments using Etags.
---
drupal-mode.el | 3 ++-
drupal/etags.el | 12 ++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/drupal-mode.el b/drupal-mode.el
index b91ce28ab5..14d655ae75 100644
--- a/drupal-mode.el
+++ b/drupal-mode.el
@@ -212,7 +212,8 @@ Used by `drupal-insert-hook' to fill in arguments on hooks.
The specified function should take two arguments: the function to
find arguments for and the drupal major version.
-See `drupal-get-function-args' (slow) and
+See `drupal-get-function-args' (slow)
+`drupal/etags-get-function-args' and
`drupal/gtags-get-function-args' for functions returning Drupal
function arguments.")
(make-variable-buffer-local 'drupal-get-function-args)
diff --git a/drupal/etags.el b/drupal/etags.el
index 08e165e958..a22b49e0f5 100644
--- a/drupal/etags.el
+++ b/drupal/etags.el
@@ -39,8 +39,20 @@
;; Set `drupal-symbol-collection' to `tags-completion-table' so
;; that inserting hooks will do completion based on etags.
+ (setq drupal-get-function-args #'drupal/etags-get-function-args)
(setq drupal-symbol-collection #'tags-completion-table)))
+(defun drupal/etags-get-function-args (symbol &optional version)
+ "Get function arguments from etags TAGS."
+ (when (and (boundp 'drupal-rootdir)
+ (file-exists-p (concat drupal-rootdir "TAGS")))
+ (with-current-buffer (find-tag-noselect symbol nil nil)
+ (goto-char (point-min))
+ (when (re-search-forward
+ (format "function\\s-+%s\\s-*(\\([^{]*\\))" symbol)
+ nil t)
+ (match-string-no-properties 1)))))
+
(add-hook 'drupal-mode-hook #'drupal/etags-enable)