Skip to content

Commit 07eaf83

Browse files
committed
New var drupal-root. Use it for `tags-file-name'.
1 parent b7f50ec commit 07eaf83

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

drupal-mode.el

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ According to http://drupal.org/coding-standards#indenting."
8282
(make-variable-buffer-local 'drupal-version)
8383
(put 'drupal-version 'safe-local-variable 'string-or-null-p)
8484

85+
(defvar drupal-root nil "Drupal project root as auto detected.")
86+
(make-variable-buffer-local 'drupal-root)
87+
(put 'drupal-root 'safe-local-variable 'string-or-null-p)
88+
8589
(defvar drupal-mode-map
8690
(let ((map (make-sparse-keymap)))
8791
(define-key map "\C-cdf" 'drupal-search-documentation)
@@ -102,6 +106,12 @@ According to http://drupal.org/coding-standards#indenting."
102106
(c-add-language 'drupal-mode 'c-mode)
103107
(c-set-style "drupal"))
104108

109+
;; setup TAGS file for etags if it exists in DRUPAL_ROOT
110+
(when (and (boundp 'drupal-root)
111+
(file-exists-p (concat drupal-root "TAGS")))
112+
(setq tags-file-name (concat drupal-root "TAGS")))
113+
114+
;; handle line ending and trailing whitespace
105115
(add-hook 'before-save-hook 'drupal-convert-line-ending)
106116
(add-hook 'before-save-hook 'drupal-delete-trailing-whitespace))
107117

@@ -204,7 +214,8 @@ should save your files with unix style end of line."
204214
(save-excursion
205215
(goto-char (point-min))
206216
(when (re-search-forward "\\(define('VERSION',\\|const VERSION =\\) +'\\(.+\\)'" nil t)
207-
(dir-locals-set-class-variables 'drupal-class `((nil . ((drupal-version . ,(match-string-no-properties 2))))))
217+
(dir-locals-set-class-variables 'drupal-class `((nil . ((drupal-version . ,(match-string-no-properties 2))
218+
(drupal-root . ,dir)))))
208219
(dir-locals-set-directory-class dir 'drupal-class)))
209220
(setq drupal-version (match-string-no-properties 2))
210221
)))

0 commit comments

Comments
 (0)