emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/drupal-mode 8e19894d55 051/308: `drupal-insert-hook' got c


From: ELPA Syncer
Subject: [nongnu] elpa/drupal-mode 8e19894d55 051/308: `drupal-insert-hook' got completing-read support.
Date: Tue, 25 Jan 2022 10:59:22 -0500 (EST)

branch: elpa/drupal-mode
commit 8e19894d5556516ebcbf85617e0bed26226ea9f7
Author: Arne Jørgensen <arne@arnested.dk>
Commit: Arne Jørgensen <arne@arnested.dk>

    `drupal-insert-hook' got completing-read support.
    
    `drupal-insert-hook' can do completing-read on hook name if a symbol
    collection of Drupal function names exists.
    
    drupal/etags.el provides a collection based on
    `tags-completion-table'.
---
 drupal-mode.el  | 10 +++++++++-
 drupal/etags.el | 10 ++++++++--
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/drupal-mode.el b/drupal-mode.el
index 389472c9b1..7957bec46c 100644
--- a/drupal-mode.el
+++ b/drupal-mode.el
@@ -310,11 +310,19 @@ should save your files with unix style end of line."
                                           (?s . ,symbol))))))))
 
 
+(defvar drupal-symbol-collection nil
+  "A collection or a function returning a collection of Drupal symbols.
+Used by `drupal-insert-hook' to provide completions on hooks.")
+(make-variable-buffer-local 'drupal-symbol-collection)
 
 (define-skeleton drupal-insert-hook
   "Insert Drupal hook function skeleton."
   nil
-  '(setq v1 (skeleton-read "Hook: " "hook_"))
+  '(setq v1 (completing-read "Hook: "
+                             (if (functionp drupal-symbol-collection)
+                                 (funcall drupal-symbol-collection)
+                               drupal-symbol-collection)
+                             nil nil "hook_"))
   "/**\n"
   " * Implements " v1 "().\n"
   " */\n"
diff --git a/drupal/etags.el b/drupal/etags.el
index 77c9a55253..540c7358e9 100644
--- a/drupal/etags.el
+++ b/drupal/etags.el
@@ -11,8 +11,14 @@
 (defun drupal/etags-enable ()
   "Setup TAGS file for etags if it exists in DRUPAL_ROOT."
   (when (and (boundp 'drupal-rootdir)
-            (file-exists-p (concat drupal-rootdir "TAGS")))
-    (setq tags-file-name (concat drupal-rootdir "TAGS"))))
+             (file-exists-p (concat drupal-rootdir "TAGS")))
+    ;; Set `tags-file-name' to the TAGS file located in
+    ;; `drupal-rootdir'.
+    (setq tags-file-name (concat drupal-rootdir "TAGS"))
+
+    ;; Set `drupal-symbol-collection' to `tags-completion-table' so
+    ;; that inserting hooks will do completion based on etags.
+    (setq drupal-symbol-collection 'tags-completion-table)))
 
 (add-hook 'drupal-mode-hook 'drupal/etags-enable)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]