[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/drupal-mode 65efa5b78a 186/308: Removed usage of directory
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/drupal-mode 65efa5b78a 186/308: Removed usage of directory local variables. |
Date: |
Tue, 25 Jan 2022 10:59:46 -0500 (EST) |
branch: elpa/drupal-mode
commit 65efa5b78a1e88749a30e7e6533c0faace5a2789
Author: Arne Jørgensen <arne@arnested.dk>
Commit: Arne Jørgensen <arne@arnested.dk>
Removed usage of directory local variables.
Fixes #12 and #42.
---
drupal-mode.el | 100 +++++++++++++++++++++++++++++++++------------------------
1 file changed, 58 insertions(+), 42 deletions(-)
diff --git a/drupal-mode.el b/drupal-mode.el
index bd9d5582f1..b085286d3c 100644
--- a/drupal-mode.el
+++ b/drupal-mode.el
@@ -558,13 +558,16 @@ Heavily based on `message-beginning-of-line' from Gnus."
+(defvar drupal-local-variables (make-hash-table :test 'equal)
+ "Drupal local variables hash table.")
+
;; Detect Drupal and Drupal version
(defun drupal-detect-drupal-version ()
"Detect if the buffer is part of a Drupal project.
If part of a Drupal project also detect the version of Drupal and
the location of DRUPAL_ROOT."
(interactive)
- (hack-local-variables)
+ (drupal-hack-local-variables)
(when (or (not drupal-version)
(not drupal-rootdir))
(dolist (file '("modules/system/system.module" "includes/bootstrap.inc"
"core/lib/Drupal.php"))
@@ -572,55 +575,68 @@ the location of DRUPAL_ROOT."
(when here
(let ((dir (locate-dominating-file here file)))
(when dir
- (with-current-buffer (find-file-noselect (concat dir file) t)
- (save-excursion
- (widen)
- (goto-char (point-min))
- (when (re-search-forward "\\(define('VERSION',\\|const
VERSION =\\) +'\\(.+\\)'" nil t)
- (dir-locals-set-class-variables 'drupal-site `((nil .
((drupal-version . ,(match-string-no-properties 2))
-
(drupal-rootdir . ,dir)))))
- (dir-locals-set-directory-class dir 'drupal-site)))
- (setq drupal-version (match-string-no-properties 2))))))))
- (hack-local-variables))
+ (with-temp-buffer
+ (insert-file-contents-literally (concat dir file))
+ (goto-char (point-min))
+ (when (re-search-forward "\\(define('VERSION',\\|const VERSION
=\\) +'\\(.+\\)'" nil t)
+ (setq drupal-version (match-string-no-properties 2))
+ (puthash (expand-file-name dir) `((drupal-version .
,drupal-version)
+ (drupal-rootdir . ,dir))
+ drupal-local-variables)))))))))
+ (drupal-hack-local-variables)
(let ((module (drupal-locate-dominating-module (or buffer-file-name
default-directory) t))
(version drupal-version)
(module-name nil)
(module-version nil)
(project nil))
(when module
- (with-current-buffer (find-file-noselect module t)
- (save-excursion
- (widen)
- (goto-char (point-min))
- (when (and (not drupal-version)
- (re-search-forward "^core *=" nil t))
- (re-search-forward " *\"?\\([^\"]+\\)\"?" (point-at-eol) t)
- (setq version (match-string-no-properties 1)))
- (goto-char (point-min))
- (when (re-search-forward "^name *=" nil t)
- (re-search-forward " *\"?\\([^\"]+\\)\"?" (point-at-eol) t)
- (setq module-name (match-string-no-properties 1)))
- (goto-char (point-min))
- (when (re-search-forward "^version *=" nil t)
- (re-search-forward " *\"?\\([^\"]+\\)\"?" (point-at-eol) t)
- (setq module-version (match-string-no-properties 1)))
- (goto-char (point-min))
- (when (re-search-forward "^project *=" nil t)
- (re-search-forward " *\"?\\([^\"]+\\)\"?" (point-at-eol) t)
- (setq project (match-string-no-properties 1)))
- (when (and (string= project "drupal")
- (string= module-version "VERSION"))
- (setq module-version version))))
- (dir-locals-set-class-variables 'drupal-module `((nil . ((drupal-module
. ,(file-name-nondirectory
-
(file-name-sans-extension module)))
- (drupal-version
. ,version)
-
(drupal-module-name . ,module-name)
-
(drupal-module-version . ,module-version)
- (drupal-project
. ,project)))))
- (dir-locals-set-directory-class (file-name-directory module)
'drupal-module)))
- (hack-local-variables)
+ (with-temp-buffer
+ (insert-file-contents-literally module)
+ (goto-char (point-min))
+ (when (and (not drupal-version)
+ (re-search-forward "^core *=" nil t))
+ (re-search-forward " *\"?\\([^\"]+\\)\"?" (point-at-eol) t)
+ (setq version (match-string-no-properties 1)))
+ (goto-char (point-min))
+ (when (re-search-forward "^name *=" nil t)
+ (re-search-forward " *\"?\\([^\"]+\\)\"?" (point-at-eol) t)
+ (setq module-name (match-string-no-properties 1)))
+ (goto-char (point-min))
+ (when (re-search-forward "^version *=" nil t)
+ (re-search-forward " *\"?\\([^\"]+\\)\"?" (point-at-eol) t)
+ (setq module-version (match-string-no-properties 1)))
+ (goto-char (point-min))
+ (when (re-search-forward "^project *=" nil t)
+ (re-search-forward " *\"?\\([^\"]+\\)\"?" (point-at-eol) t)
+ (setq project (match-string-no-properties 1)))
+ (when (and (string= project "drupal")
+ (string= module-version "VERSION"))
+ (setq module-version version))
+ (puthash (expand-file-name (file-name-directory module))
`((drupal-module . ,(file-name-nondirectory
+
(file-name-sans-extension module)))
+
(drupal-version . ,version)
+
(drupal-module-name . ,module-name)
+
(drupal-module-version . ,module-version)
+
(drupal-project . ,project))
+ drupal-local-variables))))
+ (drupal-hack-local-variables)
drupal-version)
+(defun drupal-hack-local-variables ()
+ "Drupal hack `drupal-local-variables' as buffer local variables."
+ (interactive)
+ (let ((dir (expand-file-name (or (file-name-directory buffer-file-name)
default-directory)))
+ matches)
+ (maphash (lambda (key value)
+ (when (string-match (concat "^" (regexp-quote key)) dir)
+ (add-to-list 'matches key)))
+ drupal-local-variables)
+ (sort matches #'(lambda (a b) (> (string-width a) (string-width b))))
+ (dolist (elem matches)
+ (let ((vars (gethash elem drupal-local-variables)))
+ (dolist (var vars)
+ (set (make-local-variable (car var)) (cdr-safe var)))))))
+
(defun drupal-locate-dominating-module (file &optional info-file-location)
"Look up the directory hierarchy from FILE for a Drupal module root.
Stop at the first parent where a matching module is found and
- [nongnu] elpa/drupal-mode 16632d6cf7 133/308: Fixed drush version detection for Drush 7., (continued)
- [nongnu] elpa/drupal-mode 16632d6cf7 133/308: Fixed drush version detection for Drush 7., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 58fb25a914 138/308: Added .cask to .gitignore., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode d04b119de7 141/308: Properly add our checkers to flycheck-checkers instead of enforcing it., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 5eb72aba82 162/308: Merge branch 'release/0.3.1' into develop, ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 0eac30704b 167/308: Don't delete `'trailing` form `whitespace-style` after all., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 3c32d7e938 169/308: `flycheck-declare-checker` is now `flycheck-define-checker`, ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 3cf6d3a8a9 173/308: Updated phpcs patterns to new flycheck format., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode a4768c704e 178/308: Fixed namespace of custom variable., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 5ac9531321 177/308: Added default to run flymake in place., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode b2ba37e71a 180/308: Bumped version to 0.4.0., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 65efa5b78a 186/308: Removed usage of directory local variables.,
ELPA Syncer <=
- [nongnu] elpa/drupal-mode 13b2fff6ef 196/308: Use flycheck-add-next-checker., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 507da75f31 212/308: Use `special-mode` for drush php-eval output., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 11bfbda293 217/308: Added drupal-mode to dired buffers., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode ce9d3a564f 215/308: Fixed regexp., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 75e1d2dccc 230/308: Require dependency., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 20c4d561bc 245/308: Merge branch 'release/0.6.0' into develop, ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode d03a71c891 247/308: Bump version number to 0.6.1., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode bdf3709e10 253/308: Fix bug in drupal/etags-get-function-args, ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 708f318b12 254/308: Merge pull request #64 from joddie/fix/etags-moves-point, ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode b59ad24b6e 258/308: Merge pull request #66 from joddie/fix/etags-hook-skeleton, ELPA Syncer, 2022/01/25