Skip to content

Commit 7b2c43b

Browse files
committed
Merge pull request #44 from joddie/ggtags
Add interface with gtags via `ggtags.el'
2 parents 09c622e + 135c5f6 commit 7b2c43b

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

drupal-mode.el

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,7 @@ mode-hook."
780780
(eval-after-load 'autoinsert '(require 'drupal/autoinsert))
781781
(eval-after-load 'etags '(require 'drupal/etags))
782782
(eval-after-load 'gtags '(require 'drupal/gtags))
783+
(eval-after-load 'ggtags '(require 'drupal/ggtags))
783784
(eval-after-load 'ispell '(require 'drupal/ispell))
784785
(eval-after-load 'flymake-phpcs '(require 'drupal/flymake-phpcs))
785786
(eval-after-load 'flycheck '(require 'drupal/flycheck))

drupal/ggtags.el

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
;;; drupal/ggtags.el --- Drupal-mode support for ggtags.el
2+
3+
;; Copyright (C) 2012, 2013, 2014 Arne Jørgensen
4+
5+
;; Author: Arne Jørgensen <[email protected]>
6+
7+
;; This file is part of Drupal mode.
8+
9+
;; Drupal mode is free software: you can redistribute it and/or modify
10+
;; it under the terms of the GNU General Public License as published
11+
;; by the Free Software Foundation, either version 3 of the License,
12+
;; or (at your option) any later version.
13+
14+
;; Drupal mode is distributed in the hope that it will be useful, but
15+
;; WITHOUT ANY WARRANTY; without even the implied warranty of
16+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
;; General Public License for more details.
18+
19+
;; You should have received a copy of the GNU General Public License
20+
;; along with Drupal mode. If not, see <http://www.gnu.org/licenses/>.
21+
22+
;;; Commentary:
23+
24+
;; Enable drupal-mode support for gtags.
25+
26+
;;; Code:
27+
28+
(require 'ggtags)
29+
30+
(defvar drupal/ggtags-global-command (executable-find "global")
31+
"Name of the GNU GLOBAL `global' executable.
32+
Include path to the executable if it is not in your $PATH.")
33+
34+
(defun drupal/ggtags-enable ()
35+
"Setup rootdir for gtags."
36+
(let ((dir (locate-dominating-file (or buffer-file-name default-directory) "GTAGS")))
37+
(when dir
38+
(ggtags-mode 1)
39+
;; Connect `drupal-symbol-collection' to `ggtags-mode'
40+
;; completion
41+
(setq drupal-symbol-collection
42+
(lambda () (all-completions "" ggtags-completion-table)))
43+
(setq drupal-get-function-args #'drupal/ggtags-get-function-args))))
44+
45+
(defun drupal/ggtags-get-function-args (symbol &optional version)
46+
"Get function arguments from GNU GLOBAL."
47+
(when (and (boundp 'ggtags-project-root)
48+
(file-exists-p (expand-file-name "GTAGS" ggtags-project-root)))
49+
(with-temp-buffer
50+
(ignore-errors
51+
(call-process drupal/ggtags-global-command nil t nil "-x" symbol)
52+
(goto-char (point-min))
53+
(search-forward-regexp "[^(]*(\\(.*\\))[^)]*" nil t)
54+
(match-string-no-properties 1)))))
55+
56+
(add-hook 'drupal-mode-hook #'drupal/ggtags-enable)
57+
58+
59+
60+
(provide 'drupal/ggtags)
61+
62+
;;; drupal/ggtags.el ends here

0 commit comments

Comments
 (0)