Skip to content

Commit 1d1690b

Browse files
committed
Merge branch 'release/0.5.0'
2 parents da97264 + 60b231a commit 1d1690b

File tree

3 files changed

+89
-20
lines changed

3 files changed

+89
-20
lines changed

drupal-mode.el

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
;; Author: Arne Jørgensen <[email protected]>
66
;; URL: https://github.com/arnested/drupal-mode
77
;; Created: January 17, 2012
8-
;; Version: 0.4.1
8+
;; Version: 0.5.0
99
;; Package-Requires: ((php-mode "1.5.0"))
1010
;; Keywords: programming, php, drupal
1111

@@ -387,6 +387,12 @@ of the project)."
387387
(define-key drupal-mode-map
388388
[menu-bar drupal manual]
389389
'("Drupal Mode manual" . drupal-mode-manual))
390+
(define-key drupal-mode-map
391+
[menu-bar drupal insert-hook]
392+
'("Insert hook implementation" . drupal-insert-hook))
393+
(define-key drupal-mode-map
394+
[menu-bar drupal insert-function]
395+
'("Insert function template" . drupal-insert-function))
390396
(define-key drupal-mode-map
391397
[menu-bar drupal search-documentation]
392398
'(menu-item "Search documentation" drupal-search-documentation
@@ -774,6 +780,7 @@ mode-hook."
774780
(eval-after-load 'autoinsert '(require 'drupal/autoinsert))
775781
(eval-after-load 'etags '(require 'drupal/etags))
776782
(eval-after-load 'gtags '(require 'drupal/gtags))
783+
(eval-after-load 'ggtags '(require 'drupal/ggtags))
777784
(eval-after-load 'ispell '(require 'drupal/ispell))
778785
(eval-after-load 'flymake-phpcs '(require 'drupal/flymake-phpcs))
779786
(eval-after-load 'flycheck '(require 'drupal/flycheck))

drupal/flycheck.el

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,11 @@
2828
(require 'flycheck)
2929
(require 'drupal/phpcs)
3030

31-
(defcustom drupal/flycheck-phpcs-js-and-css t
32-
"When Non-nil, override Flycheck to use PHPCS for checking CSS and JavaScript files instead of the checkers configured for css-mode and js-mode."
33-
:type `(choice
34-
(const :tag "Yes" t)
35-
(const :tag "No" nil))
36-
:group 'drupal)
37-
3831
(defun drupal/flycheck-hook ()
3932
"Enable drupal-mode support for flycheck."
40-
(when (and (apply 'derived-mode-p (append drupal-php-modes drupal-css-modes drupal-js-modes))
41-
drupal/phpcs-standard)
42-
;; Set the coding standard to "Drupal" (we checked that it is
43-
;; supported above.
33+
(when (and drupal-mode drupal/phpcs-standard)
34+
;; Set the coding standard to "Drupal" (phpcs.el has checked that
35+
;; it's supported).
4436
(setq flycheck-phpcs-standard drupal/phpcs-standard)
4537

4638
;; Flycheck will also highlight trailing whitespace as an
@@ -50,11 +42,11 @@
5042

5143
(add-hook 'drupal-mode-hook #'drupal/flycheck-hook)
5244

53-
(flycheck-define-checker css-js-phpcs
54-
"Check CSS and JavaScript using PHP_CodeSniffer.
45+
(flycheck-define-checker drupal-phpcs
46+
"Check non-PHP Drupal files using PHP_CodeSniffer.
5547
56-
PHP_CodeSniffer can be used to check non-PHP files, as exemplified by the
57-
Drupal code sniffer.
48+
The Drupal standard includes checks for non-PHP files, this
49+
checker runs those.
5850
5951
See URL `http://pear.php.net/package/PHP_CodeSniffer/'."
6052
:command ("phpcs" "--report=emacs"
@@ -72,11 +64,19 @@ See URL `http://pear.php.net/package/PHP_CodeSniffer/'."
7264
(warning line-start
7365
(file-name) ":" line ":" column ": warning - " (message)
7466
line-end))
75-
:modes (css-mode js-mode)
67+
;; We'd prefer to just check drupal-mode, but flycheck global mode
68+
;; finds the checker before we get a chance to set drupal-mode.
7669
:predicate (lambda ()
77-
(and drupal/flycheck-phpcs-js-and-css (apply 'derived-mode-p (append drupal-php-modes drupal-css-modes drupal-js-modes)))))
78-
79-
(add-to-list 'flycheck-checkers 'css-js-phpcs)
70+
(apply 'derived-mode-p (append drupal-php-modes drupal-css-modes drupal-js-modes drupal-info-modes))))
71+
72+
;; Append our custom checker.
73+
(add-to-list 'flycheck-checkers 'drupal-phpcs t)
74+
;; Add our checker as next-checker to checkers of all supported modes.
75+
(let ((modes (append drupal-css-modes drupal-js-modes drupal-info-modes)))
76+
(dolist (checker (flycheck-defined-checkers))
77+
(dolist (mode (flycheck-checker-modes checker))
78+
(if (memq mode modes)
79+
(flycheck-add-next-checker checker 'drupal-phpcs)))))
8080

8181

8282
(provide '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)