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

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

[nongnu] elpa/drupal-mode 9d793aa112 286/308: Add support for gxref/xref


From: ELPA Syncer
Subject: [nongnu] elpa/drupal-mode 9d793aa112 286/308: Add support for gxref/xref
Date: Tue, 25 Jan 2022 10:59:58 -0500 (EST)

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

    Add support for gxref/xref
---
 drupal-mode.el  |  1 +
 drupal/gxref.el | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+)

diff --git a/drupal-mode.el b/drupal-mode.el
index 4c22434358..01349754f0 100644
--- a/drupal-mode.el
+++ b/drupal-mode.el
@@ -896,6 +896,7 @@ mode-hook."
 (eval-after-load 'eldoc '(require 'drupal/eldoc))
 (eval-after-load 'etags '(require 'drupal/etags))
 (eval-after-load 'gtags '(require 'drupal/gtags))
+(eval-after-load 'gxref '(require 'drupal/gxref))
 (eval-after-load 'helm-gtags '(require 'drupal/helm-gtags))
 (eval-after-load 'ggtags '(require 'drupal/ggtags))
 (eval-after-load 'ispell '(require 'drupal/ispell))
diff --git a/drupal/gxref.el b/drupal/gxref.el
new file mode 100644
index 0000000000..61afe24398
--- /dev/null
+++ b/drupal/gxref.el
@@ -0,0 +1,68 @@
+;;; drupal/gxref.el --- Drupal-mode support for gxref
+
+;; Copyright (C) 2012, 2013, 2014, 2016, 2017 Arne Jørgensen
+
+;; Author: Arne Jørgensen <arne@arnested.dk>
+
+;; This file is part of Drupal mode.
+
+;; Drupal mode is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published
+;; by the Free Software Foundation, either version 3 of the License,
+;; or (at your option) any later version.
+
+;; Drupal mode is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with Drupal mode.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Enable drupal-mode support for gxref.
+
+;; You must have enabled gxref for this to take effect:
+
+;;   (require 'gxref)
+;;   (add-to-list 'xref-backend-functions 'gxref-xref-backend)
+
+;;; Code:
+
+(defvar drupal/gxref-global-command (if (boundp 'gxref-global-exe)
+                                        gxref-global-exe
+                                      (executable-find "global"))
+  "Name of the GNU GLOBAL `global' executable.
+Include path to the executable if it is not in your $PATH.")
+
+(defun drupal/gxref-enable ()
+  "Setup gxref for use in `drupal-mode'."
+  ;; We only setup in PHP modes for now.
+  (when (apply 'derived-mode-p drupal-php-modes)
+    ;; Setting the label is safe no matter whether we use gxref or not.
+    (set (make-local-variable 'gxref-gtags-label) "drupal")
+
+    ;; Only set symbol collection and function args getter if we think
+    ;; the user actually uses gxref (that is the user added
+    ;; `gxref-xref-backend' to `xref-backend-functions')
+    (when (and (boundp 'xref-backend-functions)
+               (memq 'gxref-xref-backend xref-backend-functions))
+      (setq drupal-symbol-collection #'(lambda ()
+                                         
(xref-backend-identifier-completion-table (xref-find-backend))))
+      (setq drupal-get-function-args #'drupal/gxref-get-function-args))))
+
+(defun drupal/gxref-get-function-args (symbol &optional version)
+  "Get function arguments for SYMBOL from GNU GLOBAL.
+Optional argument VERSION is ignored."
+  (let* ((line (car (gxref--find-symbol symbol)))
+         (string (xref-item-summary line)))
+    (string-match "(\\(.*\\))" string)
+    (match-string-no-properties 1 string)))
+
+(add-hook 'drupal-mode-hook #'drupal/gxref-enable)
+
+
+
+(provide 'drupal/gxref)
+;;; drupal/gxref.el ends here



reply via email to

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