-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
215 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
language: emacs-lisp | ||
before_install: | ||
- curl -fsSkL https://gist.githubusercontent.com/rejeep/7736123/raw | sh | ||
- export PATH="/home/travis/.cask/bin:$PATH" | ||
- export PATH="/home/travis/.evm/bin:$PATH" | ||
- evm install $EVM_EMACS --use | ||
- cask | ||
env: | ||
- EVM_EMACS=emacs-24.1-bin | ||
- EVM_EMACS=emacs-24.2-bin | ||
- EVM_EMACS=emacs-24.4-bin | ||
- EVM_EMACS=emacs-24.5-bin | ||
script: | ||
- emacs --version | ||
- make test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
;;; drupal-mode.el --- Advanced minor mode for Drupal development | ||
|
||
;; Copyright (C) 2012, 2013, 2014, 2015 Arne Jørgensen | ||
;; Copyright (C) 2012, 2013, 2014, 2015, 2016 Arne Jørgensen | ||
|
||
;; Author: Arne Jørgensen <[email protected]> | ||
;; URL: https://github.com/arnested/drupal-mode | ||
;; Created: January 17, 2012 | ||
;; Version: 0.6.1 | ||
;; Version: 0.7.0 | ||
;; Package-Requires: ((php-mode "1.5.0")) | ||
;; Keywords: programming, php, drupal | ||
|
||
|
@@ -36,6 +36,8 @@ | |
(require 'cl) | ||
(require 'php-mode) | ||
(require 'format-spec) | ||
(require 'json) | ||
(require 'sql) | ||
|
||
;; Silence byte compiler. | ||
(defvar css-indent-level) | ||
|
@@ -239,7 +241,8 @@ get better filling in Doxygen comments." | |
(?f . drupal-insert-function) | ||
(?m . drupal-module-name) | ||
(?e . drupal-drush-php-eval) | ||
(?t . drupal-wrap-string-in-t-function)) | ||
(?t . drupal-wrap-string-in-t-function) | ||
(?s . drupal-drush-sql-cli)) | ||
"Map of mnemonic keys and functions for keyboard shortcuts. | ||
See `drupal-mode-map'.") | ||
|
||
|
@@ -428,6 +431,10 @@ of the project)." | |
[menu-bar drupal cache-clear] | ||
'(menu-item "Clear all caches" drupal-drush-cache-clear | ||
:enable (and drupal-rootdir drupal-drush-program))) | ||
(define-key drupal-mode-map | ||
[menu-bar drupal sql-cli] | ||
'(menu-item "Open SQL shell" drupal-drush-sql-cli | ||
:enable (and drupal-rootdir drupal-drush-program))) | ||
|
||
(define-key drupal-mode-map | ||
[menu-bar drupal drupal-project drupal-project-bugs] | ||
|
@@ -519,6 +526,48 @@ buffer." | |
(search-forward-regexp "\\(\"\\|'\\)") | ||
(insert ")"))))) | ||
|
||
(defun drupal-drush-sql-cli () | ||
"Run a SQL shell using \"drush sql-cli\" in a SQL-mode comint buffer." | ||
(interactive) | ||
(let* ((json-object-type 'plist) | ||
(config | ||
(json-read-from-string | ||
(with-temp-buffer | ||
(call-process drupal-drush-program nil t nil | ||
"sql-conf" "--format=json") | ||
(buffer-string))))) | ||
(when (not config) | ||
(error "No Drupal SQL configuration found.")) | ||
(destructuring-bind (&key database driver &allow-other-keys) config | ||
(let ((sql-interactive-product | ||
(drupal--db-driver-to-sql-product driver)) | ||
(start-buffer (current-buffer)) | ||
(sqli-buffer | ||
(make-comint (format "SQL (%s)" database) | ||
drupal-drush-program nil "sql-cli"))) | ||
(with-current-buffer sqli-buffer | ||
(sql-interactive-mode) | ||
(set (make-local-variable 'sql-buffer) | ||
(buffer-name (current-buffer))) | ||
|
||
;; Set `sql-buffer' in the start buffer | ||
(with-current-buffer start-buffer | ||
(when (derived-mode-p 'sql-mode) | ||
(setq sql-buffer (buffer-name sqli-buffer)) | ||
(run-hooks 'sql-set-sqli-hook))) | ||
|
||
;; All done. | ||
(run-hooks 'sql-login-hook) | ||
(pop-to-buffer sqli-buffer)))))) | ||
|
||
(defun drupal--db-driver-to-sql-product (driver) | ||
"Translate a Drupal DB driver name into a sql-mode symbol." | ||
(let ((driver (intern driver))) | ||
(cond | ||
((eq driver 'pgsql) 'postgres) | ||
((assq driver sql-product-alist) driver) | ||
(t 'ansi)))) | ||
|
||
|
||
|
||
(defvar drupal-form-id-history nil | ||
|
@@ -556,7 +605,8 @@ buffer." | |
(user-error "%s already exists in file." (replace-regexp-in-string "^hook" (drupal-module-name) v2))) | ||
;; User error if the hook is already inserted elsewhere. | ||
(when (and drupal-get-function-args | ||
(funcall drupal-get-function-args (replace-regexp-in-string "^hook" (drupal-module-name) v2))) | ||
(ignore-errors | ||
(funcall drupal-get-function-args (replace-regexp-in-string "^hook" (drupal-module-name) v2)))) | ||
(user-error "%s already exists elsewhere." (replace-regexp-in-string "^hook" (drupal-module-name) v2))) | ||
(drupal-ensure-newline) | ||
"/**\n" | ||
|
@@ -872,6 +922,7 @@ mode-hook." | |
(eval-after-load 'eldoc '(require 'drupal/eldoc)) | ||
(eval-after-load 'etags '(require 'drupal/etags)) | ||
(eval-after-load 'gtags '(require 'drupal/gtags)) | ||
(eval-after-load 'helm-gtags '(require 'drupal/helm-gtags)) | ||
(eval-after-load 'ggtags '(require 'drupal/ggtags)) | ||
(eval-after-load 'ispell '(require 'drupal/ispell)) | ||
(eval-after-load 'flymake-phpcs '(require 'drupal/flymake-phpcs)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
;;; drupal/autoinsert.el --- Drupal-mode support for `auto-insert-mode' | ||
|
||
;; Copyright (C) 2012, 2013, 2014 Arne Jørgensen | ||
;; Copyright (C) 2012, 2013, 2014, 2015, 2016 Arne Jørgensen | ||
|
||
;; Author: Arne Jørgensen <[email protected]> | ||
;; Keywords: | ||
|
@@ -30,6 +30,8 @@ | |
(define-auto-insert '("\\.module" . "Drupal module file") 'drupal/autoinsert-insert-module-skeleton) | ||
(define-auto-insert '("\\.install" . "Drupal install file") 'drupal/autoinsert-insert-install-skeleton) | ||
(define-auto-insert '("\\.test" . "Drupal test file") 'drupal/autoinsert-insert-test-skeleton) | ||
(define-auto-insert '("\\.api.php" . "Drupal API file") 'drupal/autoinsert-insert-api-skeleton) | ||
(define-auto-insert '("\\.variable.inc" . "Drupal variable module support file") 'drupal/autoinsert-insert-variable-module-skeleton) | ||
|
||
(define-skeleton drupal/autoinsert-insert-info-skeleton | ||
"Drupal info file skeleton." | ||
|
@@ -95,6 +97,73 @@ | |
@ - "\n" | ||
"}\n") | ||
|
||
(define-skeleton drupal/autoinsert-insert-api-skeleton | ||
"Drupal api.php file skeleton." | ||
nil | ||
"<?php\n" | ||
"\n" | ||
"/**\n" | ||
" * @file\n" | ||
" * Hooks provided by the " (drupal-module-name) " module.\n" | ||
" */\n" | ||
"\n" | ||
"/**\n" | ||
" * @addtogroup hooks\n" | ||
" * @{\n" | ||
" */\n" | ||
"\n" | ||
@ - "\n" | ||
"\n" | ||
"/**\n" | ||
" * @} End of \"addtogroup hooks\".\n" | ||
" */\n") | ||
|
||
(define-skeleton drupal/autoinsert-insert-variable-module-skeleton | ||
"Drupal variable module support file." | ||
nil | ||
"<?php\n" | ||
"\n" | ||
"/**\n" | ||
" * @file\n" | ||
" * Variable module support for the " (drupal-module-name) " module.\n" | ||
" */\n" | ||
"\n" | ||
"/**\n" | ||
" * @addtogroup variables\n" | ||
" * @{\n" | ||
" */\n" | ||
"\n" | ||
"/**\n" | ||
" * Implements hook_variable_info().\n" | ||
" */\n" | ||
"function " (drupal-module-name) "_variable_info($options) {\n" | ||
" $variables['" @ - (drupal-module-name) "_some_variable'] = array(\n" | ||
" 'type' => 'string',\n" | ||
" 'title' => t('Some variable title', array(), $options),\n" | ||
" 'default' => 'uid',\n" | ||
" 'description' => t('Some variable description', array(), $options),\n" | ||
" 'group' => '" (drupal-module-name) "',\n" | ||
" );\n" | ||
"\n" | ||
" return $variables;\n" | ||
"}\n" | ||
"\n" | ||
"/**\n" | ||
" * Implements hook_variable_group_info().\n" | ||
" */\n" | ||
"function " (drupal-module-name) "_variable_group_info() {\n" | ||
" $groups['" (drupal-module-name) "'] = array(\n" | ||
" 'title' => t('Some group title'),\n" | ||
" 'description' => t('Some group description.'),\n" | ||
" );\n" | ||
"\n" | ||
" return $groups;\n" | ||
"}\n" | ||
"\n" | ||
"/**\n" | ||
" * @} End of \"addtogroup variables\".\n" | ||
" */\n") | ||
|
||
|
||
|
||
(provide 'drupal/autoinsert) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
;;; drupal/helm-gtags.el --- Drupal-mode support for helm-gtags | ||
|
||
;; Copyright (C) 2012, 2013, 2014, 2015, 2016 Arne Jørgensen | ||
|
||
;; Author: Arne Jørgensen <[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 drupal-mode support for helm-gtags. | ||
|
||
;;; Code: | ||
|
||
(require 'helm-gtags) | ||
|
||
(defvar drupal/helm-gtags-global-command (executable-find "global") | ||
"Name of the GNU GLOBAL `global' executable. | ||
Include path to the executable if it is not in your $PATH.") | ||
|
||
(defun drupal/helm-gtags-enable () | ||
"Setup rootdir for helm-gtags." | ||
(let ((dir (locate-dominating-file (or buffer-file-name default-directory) "GTAGS"))) | ||
(when dir | ||
(set (make-local-variable 'helm-gtags--tag-location) dir) | ||
|
||
;; Set `drupal-symbol-collection' to a call to | ||
;; `gtags-completing-gtags' so that inserting hooks will do | ||
;; completion based on gtags. | ||
(setq drupal-symbol-collection #'(lambda() (helm-gtags--complete 'tag "" nil t))) | ||
(setq drupal-get-function-args #'drupal/helm-gtags-get-function-args) | ||
(helm-gtags-mode 1)))) | ||
|
||
(defun drupal/helm-gtags-get-function-args (symbol &optional version) | ||
"Get function arguments from GNU GLOBAL." | ||
(when (file-exists-p (concat helm-gtags--tag-location "GTAGS")) | ||
(with-temp-buffer | ||
(ignore-errors | ||
(call-process drupal/helm-gtags-global-command nil t nil "-x" symbol) | ||
(goto-char (point-min)) | ||
(search-forward-regexp "[^(]*(\\(.*\\))[^)]*" nil t) | ||
(match-string-no-properties 1))))) | ||
|
||
(add-hook 'drupal-mode-hook #'drupal/helm-gtags-enable) | ||
|
||
|
||
|
||
(provide 'drupal/helm-gtags) | ||
|
||
;;; drupal/helm-gtags.el ends here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
;;; drupal/phpcs.el --- Drupal-mode common support for flymake-phpcs and flycheck | ||
|
||
;; Copyright (C) 2012, 2013 Arne Jørgensen | ||
;; Copyright (C) 2012, 2013, 2016 Arne Jørgensen | ||
|
||
;; Author: Arne Jørgensen <[email protected]> | ||
|
||
|
@@ -34,7 +34,7 @@ | |
;; command. Check for both. | ||
(call-process (or (and (boundp 'flymake-phpcs-command) (executable-find flymake-phpcs-command)) (executable-find "phpcs")) nil (list t nil) nil "-i"))))) | ||
(when (string-match | ||
"\\(Drupal[^, | ||
"\\(Drupal[^ , | ||
]*\\)" | ||
standards) | ||
(match-string-no-properties 1 standards)))) | ||
|