[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/drupal-mode c1385212f4 018/308: Add basic drush support.
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/drupal-mode c1385212f4 018/308: Add basic drush support. |
Date: |
Tue, 25 Jan 2022 10:59:03 -0500 (EST) |
branch: elpa/drupal-mode
commit c1385212f474d27faaeff5dabe261ecc4e0e3532
Author: Arne Jørgensen <arne@arnested.dk>
Commit: Arne Jørgensen <arne@arnested.dk>
Add basic drush support.
* Define a drush minor mode
* Enable drupal and drush modes if buffer-file-name matches drush
* Lookup documentation of symbols matching drush on api.drush.org
---
drupal-mode.el | 91 ++++++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 70 insertions(+), 21 deletions(-)
diff --git a/drupal-mode.el b/drupal-mode.el
index c2dd23603e..a9cfa22c27 100644
--- a/drupal-mode.el
+++ b/drupal-mode.el
@@ -44,6 +44,11 @@
:prefix "drupal-"
:group 'languages)
+(defgroup drupal-drush nil
+ "Drush configuration."
+ :prefix "drupal-drush-"
+ :group 'drupal)
+
;; Should we offer to change line endings if needed?
(defcustom drupal-convert-line-ending 'ask
"Should we offer to change line endings if needed?.
@@ -78,6 +83,29 @@ According to http://drupal.org/coding-standards#indenting."
(string :tag "Other"
"http://example.com/search?q=%s&version=%v"))
:group 'drupal)
+(defcustom drupal-drush-search-url "http://api.drush.org/api/search/%v/%s"
+ "The URL to search the Drush API.
+%v is the Drush major version.
+%s is the search term."
+ :type '(choice (const :tag "Drush.org"
"http://api.drush.org/api/search/%v/%s")
+ (string :tag "Other"
"http://example.com/search?q=%s&version=%v"))
+ :group 'drupal-drush)
+
+(defcustom drupal-drush-program (executable-find "drush")
+ "Name of the Drush program."
+ :type 'file
+ :group 'drupal-drush)
+
+(defcustom drupal-drush-version (ignore-errors
+ (replace-regexp-in-string
+ "[\n\r]" ""
+ (with-output-to-string
+ (with-current-buffer standard-output
+ (call-process drupal-drush-program nil
(list t nil) nil "--version" "--pipe")))))
+ "The installed version of Drush."
+ :type 'string
+ :group 'drupal-drush)
+
(defvar drupal-version nil "Drupal version as auto detected.")
(make-variable-buffer-local 'drupal-version)
(put 'drupal-version 'safe-local-variable 'string-or-null-p)
@@ -92,6 +120,11 @@ According to http://drupal.org/coding-standards#indenting."
map)
"Keymap for `drupal-mode'")
+(defvar drupal-drush-mode-map
+ (let ((map (make-sparse-keymap)))
+ map)
+ "Keymap for `drupal-drush-mode'")
+
;;;###autoload
@@ -99,7 +132,7 @@ According to http://drupal.org/coding-standards#indenting."
"Advanced minor mode for Drupal development.\n\n\\{drupal-mode-map}"
:group 'drupal
:init-value nil
- :lighter "/Drupal"
+ :lighter " Drupal"
:keymap drupal-mode-map
(drupal-detect-drupal-version)
(when (eq major-mode 'php-mode)
@@ -108,13 +141,21 @@ According to
http://drupal.org/coding-standards#indenting."
;; setup TAGS file for etags if it exists in DRUPAL_ROOT
(when (and (boundp 'drupal-root)
- (file-exists-p (concat drupal-root "TAGS")))
+ (file-exists-p (concat drupal-root "TAGS")))
(setq tags-file-name (concat drupal-root "TAGS")))
;; handle line ending and trailing whitespace
(add-hook 'before-save-hook 'drupal-convert-line-ending)
(add-hook 'before-save-hook 'drupal-delete-trailing-whitespace))
+(define-minor-mode drupal-drush-mode
+ "Advanced minor mode for Drupal Drush
development.\n\n\\{drupal-drush-mode-map}"
+ :group 'drupal-drush
+ :init-value nil
+ :lighter " Drush"
+ :keymap drupal-drush-mode-map
+ (drupal-mode 1))
+
;; drupal style
(defcustom drupal-style
'((c-basic-offset . 2)
@@ -193,10 +234,16 @@ should save your files with unix style end of line."
(defun drupal-search-documentation ()
"Search Drupal documentation for symbol at point."
(interactive)
- (when (symbol-at-point)
- (browse-url
- (format-spec drupal-search-url `((?v . ,(drupal-major-version
drupal-version))
- (?s . ,(symbol-at-point)))))))
+ (let ((symbol (symbol-at-point)))
+ (when symbol
+ (if (and drupal-drush-program
+ (string-match "drush" (symbol-name symbol)))
+ (browse-url
+ (format-spec drupal-drush-search-url `((?v .
,(replace-regexp-in-string "\.[0-9]+\\'" ".x" drupal-drush-version))
+ (?s . ,symbol))))
+ (browse-url
+ (format-spec drupal-search-url `((?v . ,(drupal-major-version
drupal-version))
+ (?s . ,symbol))))))))
@@ -208,20 +255,20 @@ should save your files with unix style end of line."
drupal-version
(dolist (file '("modules/system/system.module" "includes/bootstrap.inc"
"core/includes/bootstrap.inc"))
(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))
-
(drupal-root . ,dir)))))
- (dir-locals-set-directory-class dir 'drupal-class)))
- (setq drupal-version (match-string-no-properties 2))
- )))
- (hack-local-variables)
- drupal-version)))))
+ (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))
+
(drupal-root . ,dir)))))
+ (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.
@@ -249,7 +296,9 @@ mode-hook, i.e.
(when (eq major-mode 'php-mode)
(drupal-detect-drupal-version)
(when drupal-version
- (drupal-mode 1))))
+ (drupal-mode 1))
+ (when (string-match "drush" buffer-file-name)
+ (drupal-drush-mode 1))))
;;;###autoload
(eval-after-load 'php-mode
- [nongnu] branch elpa/drupal-mode created (now 17927723ad), ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 90446f5bd8 003/308: Merge branch 'release/0.1.0', ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 07eaf83729 015/308: New var drupal-root. Use it for `tags-file-name'., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 50fb7ad1f9 007/308: Add api.drupalcontrib.org for doc search., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 571f94535f 011/308: Added 'elpa-install' target., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 3f20a5b31b 008/308: Improve drupal-style indentation for comments., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 00fa57745f 005/308: Cleanup., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode b7f50ec381 012/308: Detecting version shouldn't fail on non-files., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode bcde7079ab 021/308: Moved etags support to its own file., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode c1385212f4 018/308: Add basic drush support.,
ELPA Syncer <=
- [nongnu] elpa/drupal-mode db24ec6bf9 023/308: Added gtags support to drupal-mode., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 8828357fe8 031/308: Stripped section heading lines in plain ascii., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 35c9e17240 037/308: Rewrote Makefile., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 85dabbf20a 030/308: Refactored a lot of code., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode 74fe12bd47 033/308: Bumped version to 0.2.0., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode f95aa10028 038/308: Optimized variable expansion in Makefile., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode f04ae2825d 034/308: Merge branch 'release/0.2.0', ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode c8832210b3 032/308: Documentation was rewritten and extended., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode dec5279338 041/308: Removed generated file drupal-mode.info., ELPA Syncer, 2022/01/25
- [nongnu] elpa/drupal-mode c68f560494 075/308: Fixed regexp for extracting function arguments., ELPA Syncer, 2022/01/25