branch: elpa/drupal-mode
commit 1e06f39e9f924d4df3e2cb141d94091f4eb3e61a
Author: Arne Jørgensen <[email protected]>
Commit: Arne Jørgensen <[email protected]>
Added `drupal-drush-cache-clear'.
The function will run drush to clear all Drupal caches.
Put it in the Drupal menu and on C-c d c.
---
drupal-mode.el | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drupal-mode.el b/drupal-mode.el
index 8a72d16f6a..030b67a844 100644
--- a/drupal-mode.el
+++ b/drupal-mode.el
@@ -118,6 +118,7 @@ According to http://drupal.org/coding-standards#indenting."
(defvar drupal-mode-map
(let ((map (make-sparse-keymap)))
(define-key map "\C-cdf" 'drupal-search-documentation)
+ (define-key map "\C-cdc" 'drupal-drush-cache-clear)
map)
"Keymap for `drupal-mode'")
@@ -179,6 +180,23 @@ According to http://drupal.org/coding-standards#indenting."
(interactive)
(info "drupal-mode"))
+(defun drupal-drush-cache-clear ()
+ "Clear all Drupal caches.
+Runs `drush cache-clear all'. Depends on `drupal-drush-program'
+pointing to Drush and depends on the buffer being part of a
+Drupal project (that means `drupal-rootdir' being set to the root
+of the project)."
+ (interactive)
+ (if (and drupal-rootdir
+ drupal-drush-program)
+ (let ((root drupal-rootdir))
+ (with-temp-buffer
+ (cd-absolute root)
+ (message "Clearing all caches...")
+ (call-process drupal-drush-program nil nil nil "cache-clear" "all")
+ (message "Clearing all caches...done")))
+ (message "Can't clear caches. No DRUPALROOT and/or no drush command.")))
+
;; Make a menu keymap (with a prompt string)
@@ -197,6 +215,10 @@ According to http://drupal.org/coding-standards#indenting."
(define-key drupal-mode-map
[menu-bar drupal search-documentation]
'("Search documentation" . drupal-search-documentation))
+(define-key drupal-mode-map
+ [menu-bar drupal cache-clear]
+ '(menu-item "Clear all caches" drupal-drush-cache-clear
+ :enable (and drupal-rootdir drupal-drush-program)))