branch: elpa/drupal-mode
commit ae4dd40f05514b1a8a4206339704db69fd6097f2
Author: Arne Jørgensen <[email protected]>
Commit: Arne Jørgensen <[email protected]>
Added pcomplete for drush.
Courtesy of Damon Haley.
---
drupal-mode.el | 3 +++
drupal/pcomplete.el | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 65 insertions(+)
diff --git a/drupal-mode.el b/drupal-mode.el
index 446b8bf579..0af85a91ef 100644
--- a/drupal-mode.el
+++ b/drupal-mode.el
@@ -118,6 +118,7 @@ whitespace at the end."
:group 'drupal-drush)
+;;;###autoload
(defcustom drupal-drush-program (executable-find "drush")
"Name of the Drush executable.
Include path to the executable if it is not in your $PATH."
@@ -682,6 +683,8 @@ mode-hook."
(eval-after-load 'ispell '(require 'drupal/ispell))
(eval-after-load 'flymake-phpcs '(require 'drupal/flymake-phpcs))
;;;###autoload
+(eval-after-load 'pcomplete '(require 'drupal/pcomplete))
+;;;###autoload
(eval-after-load 'webjump '(require 'drupal/webjump))
diff --git a/drupal/pcomplete.el b/drupal/pcomplete.el
new file mode 100644
index 0000000000..164b2c5476
--- /dev/null
+++ b/drupal/pcomplete.el
@@ -0,0 +1,62 @@
+;;; drupal/pcomplete.el --- Drush support for pcomplete.el
+
+;; Copyright (C) 2013 Damon Haley
+
+;; Author: Damon Haley <[email protected]>
+
+;; This file is part of Drupal mode.
+
+;; Drupal mode is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published
+;; by the Free Software Foundation, either version 3 of the License,
+;; or (at your option) any later version.
+
+;; Drupal mode is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with Drupal mode. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; Enable drush support for pcomplete.el.
+
+;;; Code:
+
+(require 'pcomplete)
+
+(defun drupal/pcomplete-drush-commands ()
+ "Return the most common drush commands by parsing the drush output."
+ (with-temp-buffer
+ (call-process drupal-drush-program nil t nil
+ "--early=includes/complete.inc")
+ (goto-char 0)
+ (let (commands)
+ (while (re-search-forward
+ "^[[:blank:]]*\\([@]?[[:word:]-.]+\\)"
+ nil t)
+ (push (match-string-no-properties 1) commands))
+ (sort commands #'string<))))
+
+(defvar drupal/pcomplete-drush-commands (drupal/pcomplete-drush-commands)
+ "List of `drush' commands.")
+
+(defun drupal/pcomplete-drush-completion ()
+ "Completion for `drush'."
+ ;; Completion for the command argument.
+ (pcomplete-here* drupal/pcomplete-drush-commands)
+ (cond
+ ((pcomplete-match "help" 1)
+ (pcomplete-here* drupal/pcomplete-drush-commands))
+ (t
+ (while (pcomplete-here (pcomplete-entries))))))
+
+(defalias 'pcomplete/drush 'drupal/pcomplete-drush-completion)
+
+
+
+(provide 'drupal/pcomplete)
+
+;;; drupal/pcomplete.el ends here