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

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

[nongnu] elpa/drupal-mode 2f8ce00821 074/308: A functions args is shown


From: ELPA Syncer
Subject: [nongnu] elpa/drupal-mode 2f8ce00821 074/308: A functions args is shown in tooltip after 5 sec of idle time.
Date: Tue, 25 Jan 2022 10:59:30 -0500 (EST)

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

    A functions args is shown in tooltip after 5 sec of idle time.
    
    If a `drupal-get-function-args' is defined (drupal/gtags.el does this)
    is defined a functions arguments is shown in a tooltip after 5 seconds
    of idle time.
---
 drupal-mode.el | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/drupal-mode.el b/drupal-mode.el
index e59ba38fe8..7228f5fdfd 100644
--- a/drupal-mode.el
+++ b/drupal-mode.el
@@ -6,7 +6,7 @@
 ;; URL: https://github.com/arnested/drupal-mode
 ;; Created: January 17, 2012
 ;; Version: 0.2.0
-;; Package-Requires: ((php-mode "1.5.0"))
+;; Package-Requires: ((php-mode "1.5.0") (pos-tip "0.4.5"))
 ;; Keywords: programming, php, drupal
 
 ;; This file is part of Drupal mode.
@@ -35,6 +35,7 @@
 
 (require 'php-mode)
 (require 'format-spec)
+(autoload 'pos-tip-show "pos-tip")
 
 
 
@@ -130,6 +131,11 @@ Include path to the executable if it is not in your $PATH."
   :link '(variable-link drupal-drush-program)
   :group 'drupal-drush)
 
+(defcustom drupal-show-function-arguments-tooltip-delay 5
+  "Show function arguments tooltip after a delay (seconds)."
+  :type '(integer)
+  :group 'drupal)
+
 ;;;###autoload
 (defcustom drupal-php-modes (list 'php-mode 'web-mode)
   "Major modes to consider PHP in Drupal mode."
@@ -218,6 +224,12 @@ Include path to the executable if it is not in your $PATH."
 
   ;; Stuff special for php-mode buffers.
   (when (apply 'derived-mode-p drupal-php-modes)
+    ;; Show function arguments from GNU GLOBAL for function at point
+    ;; after a short delay of idle time.
+    (when drupal-get-function-args
+      (run-with-idle-timer drupal-show-function-arguments-tooltip-delay t 
'drupal-get-function-args-at-point))
+
+    ;; Setup cc-mode style stuff.
     (when (derived-mode-p 'c-mode)
       (c-add-language 'drupal-mode 'c-mode)
       (c-set-style "drupal"))))
@@ -441,6 +453,15 @@ instead."
       (search-forward-regexp (concat symbol "(\\(.*\\))") nil t)
       (match-string-no-properties 1))))
 
+(defun drupal-get-function-args-at-point ()
+  "Show function arguments for function at point."
+  (interactive)
+  (when drupal-get-function-args
+    (let* ((symbol (php-get-pattern))
+           (args (funcall drupal-get-function-args symbol)))
+      (when args
+        (pos-tip-show (format "%s(%s)" symbol args))))))
+
 
 
 ;; Detect Drupal and Drupal version



reply via email to

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