branch: elpa/drupal-mode
commit b7f50ec381b6203e524e3e48b33659a77439e578
Author: Arne Jørgensen <[email protected]>
Commit: Arne Jørgensen <[email protected]>
Detecting version shouldn't fail on non-files.
---
drupal-mode.el | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/drupal-mode.el b/drupal-mode.el
index 3f518f0440..c8e4534298 100644
--- a/drupal-mode.el
+++ b/drupal-mode.el
@@ -196,18 +196,20 @@ should save your files with unix style end of line."
(if drupal-version
drupal-version
(dolist (file '("modules/system/system.module" "includes/bootstrap.inc"
"core/includes/bootstrap.inc"))
- (let ((dir (locate-dominating-file buffer-file-name file)))
- (when dir
- (with-current-buffer (find-file-noselect (concat dir file) t)
- (save-excursion
- (goto-char (point-min))
- (when (re-search-forward "\\(define('VERSION',\\|const VERSION
=\\) +'\\(.+\\)'" nil t)
- (dir-locals-set-class-variables 'drupal-class `((nil .
((drupal-version . ,(match-string-no-properties 2))))))
- (dir-locals-set-directory-class dir 'drupal-class)))
- (setq drupal-version (match-string-no-properties 2))
- )
- (hack-local-variables))))
- drupal-version))
+ (let ((here (or buffer-file-name dired-directory)))
+ (when here
+ (let ((dir (locate-dominating-file here file)))
+ (when dir
+ (with-current-buffer (find-file-noselect (concat dir file) t)
+ (save-excursion
+ (goto-char (point-min))
+ (when (re-search-forward "\\(define('VERSION',\\|const
VERSION =\\) +'\\(.+\\)'" nil t)
+ (dir-locals-set-class-variables 'drupal-class `((nil .
((drupal-version . ,(match-string-no-properties 2))))))
+ (dir-locals-set-directory-class dir 'drupal-class)))
+ (setq drupal-version (match-string-no-properties 2))
+ )))
+ (hack-local-variables)
+ drupal-version)))))
(defun drupal-major-version (&optional version)
"Return major version number of version string.