[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/drupal-mode 9c5f0066d5 071/308: Added function arguments o
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/drupal-mode 9c5f0066d5 071/308: Added function arguments on `drupal-insert-hook'. |
Date: |
Tue, 25 Jan 2022 10:59:30 -0500 (EST) |
branch: elpa/drupal-mode
commit 9c5f0066d52994019aea77fe09888437db61b88d
Author: Arne Jørgensen <arne@arnested.dk>
Commit: Arne Jørgensen <arne@arnested.dk>
Added function arguments on `drupal-insert-hook'.
Using `drupal-insert-hook' insert the function arguments for the hook.
Two functions returning these arguments are added:
`drupal-get-function-args' and `drupal/gtags-get-function-args'.
The first one is too slow for real usage. The second one is fast, but
only enabled if you use gtags.
---
drupal-mode.el | 28 +++++++++++++++++++++++++++-
drupal/gtags.el | 11 +++++++++++
2 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/drupal-mode.el b/drupal-mode.el
index 2f070f0208..c0cee4fe58 100644
--- a/drupal-mode.el
+++ b/drupal-mode.el
@@ -374,6 +374,18 @@ should save your files with unix style end of line."
Used by `drupal-insert-hook' to provide completions on hooks.")
(make-variable-buffer-local 'drupal-symbol-collection)
+(defvar drupal-get-function-args nil
+ "A function returning the function arguments for a Drupal function.
+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
+`drupal/gtags-get-function-args' for functions returning Drupal
+function arguments.")
+(make-variable-buffer-local 'drupal-get-function-args)
+
(define-skeleton drupal-insert-hook
"Insert Drupal hook function skeleton."
nil
@@ -386,7 +398,7 @@ Used by `drupal-insert-hook' to provide completions on
hooks.")
"/**\n"
" * Implements " v1 "().\n"
" */\n"
- "function " (replace-regexp-in-string "hook" (drupal-module-name) v1) "(" @
- ") {\n"
+ "function " (replace-regexp-in-string "hook" (drupal-module-name) v1) "("
(funcall drupal-get-function-args v1 (drupal-major-version)) ") {\n"
" " @ _ "\n"
"}\n")
@@ -414,6 +426,20 @@ Defaults to one blank line if optional argument NUM is not
specified."
\\{" (number-to-string var) "\\}") (line-beginning-position (- var)))
(setq result (+ 1 result))))))))
+(defun drupal-get-function-args (symbol &optional version)
+ "Get function arguments from `drupal-search-url'.
+It is really slow to download `drupal-search-url'. You should
+probably not use this. Have a look at using GNU GLOBAL / Gtags
+instead."
+ (unless version
+ (setq version (drupal-detect-drupal-version)))
+ (with-temp-buffer
+ (url-insert-file-contents (format-spec drupal-search-url `((?v . ,version)
+ (?s .
,symbol))))
+ (search-forward "<tr class=\"active\">" nil t)
+ (search-forward-regexp (concat symbol "(\\(.*\\))") nil t)
+ (match-string-no-properties 1)))
+
;; Detect Drupal and Drupal version
diff --git a/drupal/gtags.el b/drupal/gtags.el
index 21ad5cb536..96d9ae3e4b 100644
--- a/drupal/gtags.el
+++ b/drupal/gtags.el
@@ -38,8 +38,19 @@
;; `gtags-completing-gtags' so that inserting hooks will do
;; completion based on gtags.
(setq drupal-symbol-collection #'(lambda() (gtags-completing-gtags "" nil
t)))
+ (setq drupal-get-function-args #'drupal/gtags-get-function-args)
(gtags-mode 1)))
+(defun drupal/gtags-get-function-args (symbol &optional version)
+ "Get function arguments from GNU GLOBAL."
+ (when (and (boundp 'drupal-rootdir)
+ (file-exists-p (concat drupal-rootdir "GTAGS")))
+ (with-temp-buffer
+ (call-process gtags-global-command nil t nil "-x" symbol)
+ (goto-char (point-min))
+ (search-forward-regexp ".*(\\(.*\\)).*" nil t)
+ (match-string 1))))
+
(add-hook 'drupal-mode-hook #'drupal/gtags-enable)
- [nongnu] elpa/drupal-mode 080049a881 130/308: Reenable ignore-errors., (continued)
- [nongnu] elpa/drupal-mode 080049a881 130/308: Reenable ignore-errors., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 0a9d8dfa49 164/308: Cleaned whitespace., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 430b04536e 176/308: Added special case for .tpl.php extensions., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode be281df109 175/308: Added info modes. Drupal Coder Sniffer understands info files as well., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 3937ec3f40 002/308: Initial version., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 6e1ef13c5e 001/308: Initial commit, ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 7d2d703ab9 017/308: Merge branch 'feature/documentation' into develop, ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 6fbdb4e9ad 020/308: Made customization of search URLs more intuitive., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 1e06f39e9f 025/308: Added `drupal-drush-cache-clear'., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 85040ec2e5 062/308: Actually enable flymake-mode in Drupal buffers., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 9c5f0066d5 071/308: Added function arguments on `drupal-insert-hook'.,
ELPA Syncer <=
- [nongnu] elpa/drupal-mode 6b22e8c714 059/308: Added copyright and author comments., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode bb47e5d71b 086/308: Replaced nested `if's with `cond'., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode de6c1b1442 057/308: Better checking for major modes., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 5e5f6e2782 084/308: Added drupal-mode support for `auto-insert-mode'., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 511fa0de3f 104/308: Ensured file extensions are actually extensions., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 8947650b95 119/308: Rewritten Makefile to use Carton., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 043d79f4ff 127/308: Sort imenu entries by name in .make files., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 3f306071da 137/308: Drupal 8 moved the version number to a new file., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 38783166f3 143/308: Check for drupal/flycheck-phpcs-js-and-css in predicate, now we don't enforce it., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 8d57a2a3d6 146/308: Added `hash-table-p` check., ELPA Syncer, 2022/01/25