From 557f34c5d3521f3045f48b0f2d4b1aeca13c2356 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Wed, 27 Nov 2013 23:29:13 +0100 Subject: [PATCH 01/29] Fixed tar on Mac OS X. In a better way than 4adeb0c218a479aa7d8c168a4a1ea4b7bc870211. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index fa4603b..808de21 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ CASK?=cask EMACS?=emacs -TAR?=bsdtar +TAR?=COPYFILE_DISABLE=1 bsdtar PANDOC?=pandoc --atx-headers VERSION?=$(shell $(CASK) version) @@ -46,7 +46,7 @@ $(ARCHIVE_NAME)-pkg.el: $(ARCHIVE_NAME).el # create a tar ball in package.el format for uploading to http://marmalade-repo.org $(PACKAGE_NAME).tar: README $(ARCHIVE_NAME).el $(ARCHIVE_NAME)-pkg.el $(ARCHIVE_NAME).info dir drupal/*.el drupal-tests.el drush-make-mode.el - COPYFILE_DISABLE=1 $(TAR) -c -s "@^@$(PACKAGE_NAME)/@" -f $(PACKAGE_NAME).tar $^ + $(TAR) -c -s "@^@$(PACKAGE_NAME)/@" -f $(PACKAGE_NAME).tar $^ install: $(PACKAGE_NAME).tar $(EMACS) --batch -l package -f package-initialize --eval "(package-install-file \"$(PWD)/$(PACKAGE_NAME).tar\")" From 0a9d8dfa4991c1f96f755efc8d05b4c4e65e8bf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Wed, 27 Nov 2013 23:39:44 +0100 Subject: [PATCH 02/29] Cleaned whitespace. --- drupal-mode.el | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drupal-mode.el b/drupal-mode.el index 2773a02..7d75e17 100644 --- a/drupal-mode.el +++ b/drupal-mode.el @@ -36,7 +36,7 @@ (require 'php-mode) (require 'format-spec) -(eval-when-compile +(eval-when-compile (require 'css-mode)) @@ -62,7 +62,7 @@ If `Ask' ask the user whether to convert line endings. Drupal coding standards states that all text files should end in a single newline (\\n)." - :type `(choice + :type `(choice :tag " we offer to change line endings if needed?" (const :tag "Always" t) (const :tag "Never" nil) @@ -83,7 +83,7 @@ If `Default' do what the global setting is. Drupal coding standards states that lines should have no trailing whitespace at the end." - :type `(choice + :type `(choice :tag "Whether to delete all the trailing whitespace." (const :tag "Always" always) (const :tag "Default" default) @@ -538,12 +538,12 @@ Heavily based on `message-beginning-of-line' from Gnus." (set zrs t))) (if (derived-mode-p 'conf-mode) (let* ((here (point)) - (bol (progn (beginning-of-line n) (point))) - (eol (point-at-eol)) - (eoh (re-search-forward "= *" eol t))) - (goto-char - (if (and eoh (or (< eoh here) (= bol here))) - eoh bol))) + (bol (progn (beginning-of-line n) (point))) + (eol (point-at-eol)) + (eoh (re-search-forward "= *" eol t))) + (goto-char + (if (and eoh (or (< eoh here) (= bol here))) + eoh bol))) (beginning-of-line n))) From 4e4714fc1652ae809b78d1724bb73f46176463f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Wed, 27 Nov 2013 23:42:25 +0100 Subject: [PATCH 03/29] ... --- drupal/autoinsert.el | 2 +- drupal/emacs-drush.el | 2 +- drupal/phpcs.el | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drupal/autoinsert.el b/drupal/autoinsert.el index 751bbdc..f9fe01d 100644 --- a/drupal/autoinsert.el +++ b/drupal/autoinsert.el @@ -3,7 +3,7 @@ ;; Copyright (C) 2012, 2013 Arne Jørgensen ;; Author: Arne Jørgensen -;; Keywords: +;; Keywords: ;; This file is part of Drupal mode. diff --git a/drupal/emacs-drush.el b/drupal/emacs-drush.el index bc62452..dad8c57 100644 --- a/drupal/emacs-drush.el +++ b/drupal/emacs-drush.el @@ -38,7 +38,7 @@ On `after-save-hook' run `drush etags' or `drush gtags'. Requires `Drush utilities for Emacs users' to be installed." - :type `(choice + :type `(choice (const :tag "Yes" t) (const :tag "No" nil)) :link '(url-link :tag "Drush utilities for Emacs users" "https://drupal.org/project/emacs_drush") diff --git a/drupal/phpcs.el b/drupal/phpcs.el index c9fd848..d889030 100644 --- a/drupal/phpcs.el +++ b/drupal/phpcs.el @@ -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)))) From 493acf44da901ee746559d80c83182f19dd33027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Wed, 27 Nov 2013 23:43:07 +0100 Subject: [PATCH 04/29] Redone building `drupal-mode-map`. This way it is easier to also add the mnemonic keys / functions to other key bindings. I.e. I do the following in my .emacs to map them to the hyper key: ``` (add-hook 'drupal-mode-hook (lambda () (dolist (elem drupal-mode-map-alist) (local-set-key `[(hyper ,(car elem))] (cdr elem))))) ``` --- drupal-mode.el | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/drupal-mode.el b/drupal-mode.el index 7d75e17..e87a75f 100644 --- a/drupal-mode.el +++ b/drupal-mode.el @@ -188,14 +188,23 @@ Include path to the executable if it is not in your $PATH." (make-variable-buffer-local 'drupal-project) (put 'drupal-project 'safe-local-variable 'string-or-null-p) +(defvar drupal-mode-map-alist + '((?d . drupal-search-documentation) + (?c . drupal-drush-cache-clear) + (?h . drupal-insert-hook) + (?f . drupal-insert-function) + (?m . drupal-module-name) + (?t . drupal-wrap-string-in-t-function)) + "Map of mnemonic keys and functions for keyboard shortcuts. +See `drupal-mode-map'.") + (defvar drupal-mode-map (let ((map (make-sparse-keymap))) - (define-key map [(control c) (control v) (control d)] #'drupal-search-documentation) - (define-key map [(control c) (control v) (control c)] #'drupal-drush-cache-clear) - (define-key map [(control c) (control v) (control h)] #'drupal-insert-hook) - (define-key map [(control c) (control v) (control f)] #'drupal-insert-function) - (define-key map [(control c) (control v) (control m)] #'drupal-module-name) - (define-key map [(control c) (control v) (control t)] #'drupal-wrap-string-in-t-function) + ;; Iterate `drupal-mode-map-alist' and assign the functions to the + ;; mode map on C-c C-v C-`mnemonic-key'. + (dolist (elem drupal-mode-map-alist) + (define-key map `[(control c) (control v) (control ,(car elem))] (cdr elem))) + (define-key map [(control a)] #'drupal-mode-beginning-of-line) map) "Keymap for `drupal-mode'") From 0eac30704b0cbe214cfe017c148b6a420f8f1834 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Wed, 27 Nov 2013 23:46:05 +0100 Subject: [PATCH 05/29] Don't delete `'trailing` form `whitespace-style` after all. `whitespace-style` not only decides what kind of whitespace gets highlighted by `whitespace-mode` but also what kind of whitespace gets removed by `whitespace-cleanup`. --- drupal/phpcs.el | 2 -- 1 file changed, 2 deletions(-) diff --git a/drupal/phpcs.el b/drupal/phpcs.el index d889030..723f9fa 100644 --- a/drupal/phpcs.el +++ b/drupal/phpcs.el @@ -60,8 +60,6 @@ need to highlight it twice." (defun drupal/phpcs-dont-show-trailing-whitespace () "Turn of various trailing white space highlighting." (when drupal/phpcs-dont-show-trailing-whitespace - (when (boundp 'whitespace-style) - (set (make-local-variable 'whitespace-style) (remove 'trailing whitespace-style))) (setq show-trailing-whitespace nil))) (provide 'drupal/phpcs) From 31c2b672aa25fad47e3a8ef6a4d2db4318a7a7dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Mon, 9 Dec 2013 09:03:32 +0100 Subject: [PATCH 06/29] Added Api.drupalize.me as `drupal-search-url` option. --- drupal-mode.el | 1 + 1 file changed, 1 insertion(+) diff --git a/drupal-mode.el b/drupal-mode.el index e87a75f..e1ac5f1 100644 --- a/drupal-mode.el +++ b/drupal-mode.el @@ -98,6 +98,7 @@ whitespace at the end." %s is the search term." :type '(choice (const :tag "Api.drupal.org" "http://api.drupal.org/api/search/%v/%s") (const :tag "Api.drupalcontrib.org" "http://api.drupalcontrib.org/api/search/%v/%s") + (const :tag "Api.drupalize.me" "http://api.drupalize.me/api/search/%v/%s") (string :tag "Other" "http://example.com/api/search/%v/%s")) :link '(url-link :tag "api.drupalcontrib.org" "http://api.drupalcontrib.org") :link '(url-link :tag "api.drupal.org" "http://api.drupal.org") From 3c32d7e938eda3d3e8c6bf28a08ea6ddf7b51bae Mon Sep 17 00:00:00 2001 From: spaceotter Date: Wed, 1 Jan 2014 14:32:11 +0100 Subject: [PATCH 07/29] `flycheck-declare-checker` is now `flycheck-define-checker` Fixes #38. --- drupal/flycheck.el | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drupal/flycheck.el b/drupal/flycheck.el index 1aef618..ff047a3 100644 --- a/drupal/flycheck.el +++ b/drupal/flycheck.el @@ -1,6 +1,6 @@ ;;; drupal/flycheck.el --- Drupal-mode support for flycheck and phpcs -;; Copyright (C) 2012, 2013 Arne Jørgensen +;; Copyright (C) 2012, 2013, 2014 Arne Jørgensen ;; Author: Thomas Fini Hansen @@ -25,6 +25,9 @@ ;;; Code: +(eval-when-compile + (require 'flycheck)) + (require 'drupal/phpcs) (defcustom drupal/flycheck-phpcs-js-and-css t @@ -48,27 +51,28 @@ (add-hook 'drupal-mode-hook #'drupal/flycheck-hook) -(flycheck-declare-checker css-js-phpcs +(flycheck-define-checker css-js-phpcs "Check CSS and JavaScript using PHP_CodeSniffer. PHP_CodeSniffer can be used to check non-PHP files, as exemplified by the Drupal code sniffer. See URL `http://pear.php.net/package/PHP_CodeSniffer/'." - :command '("phpcs" "--report=emacs" - (option "--standard=" flycheck-phpcs-standard) - source) + :command ("phpcs" "--report=emacs" + (option "--standard=" flycheck-phpcs-standard) + source) ;; Though phpcs supports Checkstyle output which we could feed to ;; `flycheck-parse-checkstyle', we are still using error patterns here, ;; because PHP has notoriously unstable output habits. See URL ;; `https://github.com/lunaryorn/flycheck/issues/78' and URL ;; `https://github.com/lunaryorn/flycheck/issues/118' :error-patterns - '(("\\(?1:.*\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\): error - \\(?4:.*\\)" error) - ("\\(?1:.*\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\): warning - \\(?4:.*\\)" warning)) - :modes '(css-mode js-mode) + ((error "\\(?1:.*\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\): error - \\(?4:.*\\)") + (warning "\\(?1:.*\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\): warning - \\(?4:.*\\)")) + :modes (css-mode js-mode) :predicate (lambda () (and drupal/flycheck-phpcs-js-and-css (apply 'derived-mode-p (append drupal-php-modes drupal-css-modes drupal-js-modes))))) + (add-to-list 'flycheck-checkers 'css-js-phpcs) From 46ad71de46d678323740144317c5bee37d159221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Fri, 3 Jan 2014 10:53:23 +0100 Subject: [PATCH 08/29] Used `default-directory` as fallback if `buffer-file-name` us not set. --- drupal/etags.el | 4 ++-- drupal/gtags.el | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drupal/etags.el b/drupal/etags.el index ee22511..6c23a7e 100644 --- a/drupal/etags.el +++ b/drupal/etags.el @@ -1,6 +1,6 @@ ;;; drupal/etags.el --- Drupal-mode support for etags -;; Copyright (C) 2012, 2013 Arne Jørgensen +;; Copyright (C) 2012, 2013, 2014 Arne Jørgensen ;; Author: Arne Jørgensen @@ -29,7 +29,7 @@ (defun drupal/etags-enable () "Setup TAGS file for etags if it exists." - (let ((dir (locate-dominating-file (buffer-file-name) "TAGS"))) + (let ((dir (locate-dominating-file (or buffer-file-name default-directory) "TAGS"))) (when dir (set (make-local-variable 'drupal/etags-rootdir) dir) diff --git a/drupal/gtags.el b/drupal/gtags.el index ee48eb6..9e67276 100644 --- a/drupal/gtags.el +++ b/drupal/gtags.el @@ -1,6 +1,6 @@ ;;; drupal/gtags.el --- Drupal-mode support for gtags -;; Copyright (C) 2012, 2013 Arne Jørgensen +;; Copyright (C) 2012, 2013, 2014 Arne Jørgensen ;; Author: Arne Jørgensen @@ -35,7 +35,7 @@ Include path to the executable if it is not in your $PATH.") (defun drupal/gtags-enable () "Setup rootdir for gtags." - (let ((dir (locate-dominating-file (buffer-file-name) "GTAGS"))) + (let ((dir (locate-dominating-file (or buffer-file-name default-directory) "GTAGS"))) (when dir (set (make-local-variable 'gtags-rootdir) dir) From 2b71509ac3ecc74009114a43300ea5973c477210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Fri, 3 Jan 2014 10:58:45 +0100 Subject: [PATCH 09/29] Used `(buffer-name)` as fallback if `buffer-file-name` us not set. --- drupal-mode.el | 4 ++-- drupal/autoinsert.el | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drupal-mode.el b/drupal-mode.el index e1ac5f1..0de6255 100644 --- a/drupal-mode.el +++ b/drupal-mode.el @@ -1,6 +1,6 @@ ;;; drupal-mode.el --- Advanced minor mode for Drupal development -;; Copyright (C) 2012, 2013 Arne Jørgensen +;; Copyright (C) 2012, 2013, 2014 Arne Jørgensen ;; Author: Arne Jørgensen ;; URL: https://github.com/arnested/drupal-mode @@ -676,7 +676,7 @@ Used in `drupal-insert-hook' and `drupal-insert-function'." drupal-module ;; Otherwise fall back to a very naive ;; way of guessing the module name. - (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))))) + (file-name-nondirectory (file-name-sans-extension (or buffer-file-name (buffer-name)))))))) (if (called-interactively-p 'any) (insert name) name))) diff --git a/drupal/autoinsert.el b/drupal/autoinsert.el index f9fe01d..e86143f 100644 --- a/drupal/autoinsert.el +++ b/drupal/autoinsert.el @@ -1,6 +1,6 @@ ;;; drupal/autoinsert.el --- Drupal-mode support for `auto-insert-mode' -;; Copyright (C) 2012, 2013 Arne Jørgensen +;; Copyright (C) 2012, 2013, 2014 Arne Jørgensen ;; Author: Arne Jørgensen ;; Keywords: @@ -34,7 +34,7 @@ (define-skeleton drupal/autoinsert-insert-info-skeleton "Drupal info file skeleton." nil - '(setq v1 (file-name-nondirectory (file-name-sans-extension (buffer-file-name)))) + '(setq v1 (file-name-nondirectory (file-name-sans-extension (or buffer-file-name (buffer-name)))) '(setq v2 (if (drupal-major-version) (>= (string-to-number (drupal-major-version)) 7) t)) "name = " @ - (upcase-initials (replace-regexp-in-string "[-_\\.]+" " " v1)) \n "description = " @ \n From 6bb266bc11db76be1aa802d70a7d4cd66fae97fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Fri, 3 Jan 2014 11:38:27 +0100 Subject: [PATCH 10/29] Fixed typo in latest commit. --- drupal/autoinsert.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drupal/autoinsert.el b/drupal/autoinsert.el index e86143f..1aa29d8 100644 --- a/drupal/autoinsert.el +++ b/drupal/autoinsert.el @@ -34,7 +34,7 @@ (define-skeleton drupal/autoinsert-insert-info-skeleton "Drupal info file skeleton." nil - '(setq v1 (file-name-nondirectory (file-name-sans-extension (or buffer-file-name (buffer-name)))) + '(setq v1 (file-name-nondirectory (file-name-sans-extension (or buffer-file-name (buffer-name))))) '(setq v2 (if (drupal-major-version) (>= (string-to-number (drupal-major-version)) 7) t)) "name = " @ - (upcase-initials (replace-regexp-in-string "[-_\\.]+" " " v1)) \n "description = " @ \n From 3cf6d3a8a9feea44647f7e866fd0e309039e7139 Mon Sep 17 00:00:00 2001 From: Thomas Fini Hansen Date: Fri, 3 Jan 2014 13:42:17 +0100 Subject: [PATCH 11/29] Updated phpcs patterns to new flycheck format. --- drupal/flycheck.el | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drupal/flycheck.el b/drupal/flycheck.el index ff047a3..d671587 100644 --- a/drupal/flycheck.el +++ b/drupal/flycheck.el @@ -67,8 +67,12 @@ See URL `http://pear.php.net/package/PHP_CodeSniffer/'." ;; `https://github.com/lunaryorn/flycheck/issues/78' and URL ;; `https://github.com/lunaryorn/flycheck/issues/118' :error-patterns - ((error "\\(?1:.*\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\): error - \\(?4:.*\\)") - (warning "\\(?1:.*\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\): warning - \\(?4:.*\\)")) + ((error line-start + (file-name) ":" line ":" column ": error - " (message) + line-end) + (warning line-start + (file-name) ":" line ":" column ": warning - " (message) + line-end)) :modes (css-mode js-mode) :predicate (lambda () (and drupal/flycheck-phpcs-js-and-css (apply 'derived-mode-p (append drupal-php-modes drupal-css-modes drupal-js-modes))))) From be281df10964c9936788e571ed2c8acc758b132c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Sat, 11 Jan 2014 11:32:27 +0100 Subject: [PATCH 12/29] Added info modes. Drupal Coder Sniffer understands info files as well. --- drupal/flymake-phpcs.el | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drupal/flymake-phpcs.el b/drupal/flymake-phpcs.el index 671e3a1..a75d762 100644 --- a/drupal/flymake-phpcs.el +++ b/drupal/flymake-phpcs.el @@ -1,6 +1,6 @@ ;;; drupal/flymake-phpcs.el --- Drupal-mode support for flymake-phpcs -;; Copyright (C) 2012, 2013 Arne Jørgensen +;; Copyright (C) 2012, 2013, 2014 Arne Jørgensen ;; Author: Arne Jørgensen @@ -33,8 +33,8 @@ (require 'drupal/phpcs) (defun drupal/flymake-phpcs-enable () - "Enable drupal-mode support for flymake-phpcs." - (when (and (apply 'derived-mode-p (append drupal-php-modes drupal-css-modes drupal-js-modes)) + "Enable drupal-mode support for flymake-phpcs."(interactive) + (when (and (apply 'derived-mode-p (append drupal-php-modes drupal-css-modes drupal-js-modes drupal-info-modes)) (executable-find flymake-phpcs-command) drupal/phpcs-standard) ;; Set the coding standard to "Drupal" (we checked that it is From 430b04536e1980e9cbd7bbaac6ef45cf79526c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Sat, 11 Jan 2014 11:33:34 +0100 Subject: [PATCH 13/29] Added special case for .tpl.php extensions. --- drupal/flymake-phpcs.el | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drupal/flymake-phpcs.el b/drupal/flymake-phpcs.el index a75d762..d861bf3 100644 --- a/drupal/flymake-phpcs.el +++ b/drupal/flymake-phpcs.el @@ -49,8 +49,11 @@ ;; version of `flymake-allowed-file-name-masks' and make ;; flymake-phpcs initialize. (make-local-variable 'flymake-allowed-file-name-masks) - (add-to-list 'flymake-allowed-file-name-masks - `(,(concat "\\." (file-name-extension (or buffer-file-name (buffer-name))) "\\'") flymake-phpcs-init)) + (let ((extension (file-name-extension (or buffer-file-name (buffer-name))))) + (when (string-match "\\.tpl\\.php\\'" (or buffer-file-name (buffer-name))) + (setq extension "tpl\\.php")) + (add-to-list 'flymake-allowed-file-name-masks + `(,(concat "\\." extension "\\'") flymake-phpcs-init))) (flymake-mode 1))) (add-hook 'drupal-mode-hook #'drupal/flymake-phpcs-enable) From 5ac95313210d3e3d39148acb3c74bf02c9a8f48a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Sat, 11 Jan 2014 12:07:03 +0100 Subject: [PATCH 14/29] Added default to run flymake in place. --- drupal/flymake-phpcs.el | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drupal/flymake-phpcs.el b/drupal/flymake-phpcs.el index d861bf3..ac50b0b 100644 --- a/drupal/flymake-phpcs.el +++ b/drupal/flymake-phpcs.el @@ -32,6 +32,29 @@ (define-obsolete-variable-alias 'drupal/flymake-phpcs-dont-show-trailing-whitespace 'drupal/phpcs-dont-show-trailing-whitespace) (require 'drupal/phpcs) +;; Only available when `flymake' is the fork from +;; https://github.com/illusori/emacs-flymake. +(when (boundp 'flymake-run-in-place) + (defcustom drupal/flymake-run-in-place t + "If nil, flymake will run on copies in `temporary-file-directory' rather +than the same directory as the original file. + +Drupal Coder Sniffer has some sniffs that will only work if run in place. + +Defaults to `t'. Set to `default' to use whatever +`flymake-run-in-place' is set to. + +When editing a remote file via Tramp, this flag also has the side-effect of +determining whether the syntax check is run in the same place as the original +file (and thus on the remote machine), or in the same place as +`temporary-file-directory' (usually the local machine)." + :type `(choice + (const :tag "Yes" t) + (const :tag "No" nil) + (const :tag "Default" default)) + :link '(url-link :tag "Drupal Coder Sniffer" "https://drupal.org/project/coder") + :group 'drupal)) + (defun drupal/flymake-phpcs-enable () "Enable drupal-mode support for flymake-phpcs."(interactive) (when (and (apply 'derived-mode-p (append drupal-php-modes drupal-css-modes drupal-js-modes drupal-info-modes)) @@ -41,6 +64,11 @@ ;; supported above. (set (make-local-variable 'flymake-phpcs-standard) drupal/phpcs-standard) + ;; Set whether flymake runs in place. + (when (and (boundp 'drupal/flymake-run-in-place) + (not (eq drupal/flymake-run-in-place 'default))) + (set (make-local-variable 'flymake-run-in-place) drupal/flymake-run-in-place)) + ;; Flymake-phpcs will also highlight trailing whitespace as an ;; error so no need to highlight it twice. (drupal/phpcs-dont-show-trailing-whitespace) From a4768c704e1a36f441cedb5b73f02514f32528c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Sat, 11 Jan 2014 14:40:25 +0100 Subject: [PATCH 15/29] Fixed namespace of custom variable. --- drupal/flymake-phpcs.el | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drupal/flymake-phpcs.el b/drupal/flymake-phpcs.el index ac50b0b..3b285b5 100644 --- a/drupal/flymake-phpcs.el +++ b/drupal/flymake-phpcs.el @@ -35,7 +35,7 @@ ;; Only available when `flymake' is the fork from ;; https://github.com/illusori/emacs-flymake. (when (boundp 'flymake-run-in-place) - (defcustom drupal/flymake-run-in-place t + (defcustom drupal/flymake-phpcs-run-in-place t "If nil, flymake will run on copies in `temporary-file-directory' rather than the same directory as the original file. @@ -65,9 +65,9 @@ file (and thus on the remote machine), or in the same place as (set (make-local-variable 'flymake-phpcs-standard) drupal/phpcs-standard) ;; Set whether flymake runs in place. - (when (and (boundp 'drupal/flymake-run-in-place) - (not (eq drupal/flymake-run-in-place 'default))) - (set (make-local-variable 'flymake-run-in-place) drupal/flymake-run-in-place)) + (when (and (boundp 'drupal/flymake-phpcs-run-in-place) + (not (eq drupal/flymake-phpcs-run-in-place 'default))) + (set (make-local-variable 'flymake-run-in-place) drupal/flymake-phpcs-run-in-place)) ;; Flymake-phpcs will also highlight trailing whitespace as an ;; error so no need to highlight it twice. From a25b4df69a8c23920cada4392901ff07ae6e7d21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Sat, 11 Jan 2014 15:01:44 +0100 Subject: [PATCH 16/29] Cope with different implementations of flymake-phpcs. --- drupal/flymake-phpcs.el | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drupal/flymake-phpcs.el b/drupal/flymake-phpcs.el index 3b285b5..65bb429 100644 --- a/drupal/flymake-phpcs.el +++ b/drupal/flymake-phpcs.el @@ -34,7 +34,8 @@ ;; Only available when `flymake' is the fork from ;; https://github.com/illusori/emacs-flymake. -(when (boundp 'flymake-run-in-place) +(when (or (boundp 'flymake-run-in-place) + (fboundp 'flymake-phpcs-load)) (defcustom drupal/flymake-phpcs-run-in-place t "If nil, flymake will run on copies in `temporary-file-directory' rather than the same directory as the original file. @@ -61,12 +62,16 @@ file (and thus on the remote machine), or in the same place as (executable-find flymake-phpcs-command) drupal/phpcs-standard) ;; Set the coding standard to "Drupal" (we checked that it is - ;; supported above. + ;; supported above). (set (make-local-variable 'flymake-phpcs-standard) drupal/phpcs-standard) ;; Set whether flymake runs in place. (when (and (boundp 'drupal/flymake-phpcs-run-in-place) (not (eq drupal/flymake-phpcs-run-in-place 'default))) + (when (fboundp 'flymake-phpcs-load) + (if drupal/flymake-phpcs-run-in-place + (set (make-local-variable 'flymake-phpcs-location) 'inplace) + (set (make-local-variable 'flymake-phpcs-location) 'tempdir))) (set (make-local-variable 'flymake-run-in-place) drupal/flymake-phpcs-run-in-place)) ;; Flymake-phpcs will also highlight trailing whitespace as an @@ -76,13 +81,15 @@ file (and thus on the remote machine), or in the same place as ;; This is a php-mode file so add the extension to a buffer locale ;; version of `flymake-allowed-file-name-masks' and make ;; flymake-phpcs initialize. - (make-local-variable 'flymake-allowed-file-name-masks) - (let ((extension (file-name-extension (or buffer-file-name (buffer-name))))) - (when (string-match "\\.tpl\\.php\\'" (or buffer-file-name (buffer-name))) - (setq extension "tpl\\.php")) - (add-to-list 'flymake-allowed-file-name-masks - `(,(concat "\\." extension "\\'") flymake-phpcs-init))) - (flymake-mode 1))) + (if (fboundp 'flymake-phpcs-load) + (flymake-phpcs-load) + (make-local-variable 'flymake-allowed-file-name-masks) + (let ((extension (file-name-extension (or buffer-file-name (buffer-name))))) + (when (string-match "\\.tpl\\.php\\'" (or buffer-file-name (buffer-name))) + (setq extension "tpl\\.php")) + (add-to-list 'flymake-allowed-file-name-masks + `(,(concat "\\." extension "\\'") flymake-phpcs-init))) + (flymake-mode 1)))) (add-hook 'drupal-mode-hook #'drupal/flymake-phpcs-enable) From b2ba37e71a45dbb03649c8f98c23d8f8a2f72788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Sun, 12 Jan 2014 23:11:04 +0100 Subject: [PATCH 17/29] Bumped version to 0.4.0. --- drupal-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drupal-mode.el b/drupal-mode.el index 0de6255..d74620b 100644 --- a/drupal-mode.el +++ b/drupal-mode.el @@ -5,7 +5,7 @@ ;; Author: Arne Jørgensen ;; URL: https://github.com/arnested/drupal-mode ;; Created: January 17, 2012 -;; Version: 0.3.1 +;; Version: 0.4.0 ;; Package-Requires: ((php-mode "1.5.0")) ;; Keywords: programming, php, drupal From 3bb1e40acc5d05c5ff51998b94bb35ef1c03f0ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Mon, 13 Jan 2014 23:40:34 +0100 Subject: [PATCH 18/29] Silence byte compiler. --- drupal-mode.el | 4 ++-- drupal/flycheck.el | 7 +++---- drupal/flymake-phpcs.el | 6 +++++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/drupal-mode.el b/drupal-mode.el index d74620b..bd9d558 100644 --- a/drupal-mode.el +++ b/drupal-mode.el @@ -36,8 +36,8 @@ (require 'php-mode) (require 'format-spec) -(eval-when-compile - (require 'css-mode)) +;; Silence byte compiler. +(defvar css-indent-level) diff --git a/drupal/flycheck.el b/drupal/flycheck.el index d671587..84d5da1 100644 --- a/drupal/flycheck.el +++ b/drupal/flycheck.el @@ -25,9 +25,7 @@ ;;; Code: -(eval-when-compile - (require 'flycheck)) - +(require 'flycheck) (require 'drupal/phpcs) (defcustom drupal/flycheck-phpcs-js-and-css t @@ -47,7 +45,8 @@ ;; Flycheck will also highlight trailing whitespace as an ;; error so no need to highlight it twice. - (drupal/phpcs-dont-show-trailing-whitespace))) + (when (fboundp 'drupal/phpcs-dont-show-trailing-whitespace) + (drupal/phpcs-dont-show-trailing-whitespace)))) (add-hook 'drupal-mode-hook #'drupal/flycheck-hook) diff --git a/drupal/flymake-phpcs.el b/drupal/flymake-phpcs.el index 65bb429..1ccc393 100644 --- a/drupal/flymake-phpcs.el +++ b/drupal/flymake-phpcs.el @@ -32,6 +32,9 @@ (define-obsolete-variable-alias 'drupal/flymake-phpcs-dont-show-trailing-whitespace 'drupal/phpcs-dont-show-trailing-whitespace) (require 'drupal/phpcs) +;; Silence byte compiler. +(defvar flymake-phpcs-location) + ;; Only available when `flymake' is the fork from ;; https://github.com/illusori/emacs-flymake. (when (or (boundp 'flymake-run-in-place) @@ -76,7 +79,8 @@ file (and thus on the remote machine), or in the same place as ;; Flymake-phpcs will also highlight trailing whitespace as an ;; error so no need to highlight it twice. - (drupal/phpcs-dont-show-trailing-whitespace) + (when (fboundp 'drupal/phpcs-dont-show-trailing-whitespace) + (drupal/phpcs-dont-show-trailing-whitespace)) ;; This is a php-mode file so add the extension to a buffer locale ;; version of `flymake-allowed-file-name-masks' and make From b929895d51f2549e336db595a877232834dd2ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Mon, 13 Jan 2014 23:41:07 +0100 Subject: [PATCH 19/29] Added own implementation of flymake init and temp names. Implemented our own versions of `flymake-create-temp-inplace` and `flymake-create-temp-intemp`. We need them to ensure better temporary file names to comply well with Drupal Coder Sniffer. We need the new `drupal/flymake-phpcs-init` to call our own temporary file name functions. Simplified setting `flymake-allowed-file-name-masks`. --- drupal/flymake-phpcs.el | 73 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 5 deletions(-) diff --git a/drupal/flymake-phpcs.el b/drupal/flymake-phpcs.el index 1ccc393..0aa073c 100644 --- a/drupal/flymake-phpcs.el +++ b/drupal/flymake-phpcs.el @@ -88,13 +88,76 @@ file (and thus on the remote machine), or in the same place as (if (fboundp 'flymake-phpcs-load) (flymake-phpcs-load) (make-local-variable 'flymake-allowed-file-name-masks) - (let ((extension (file-name-extension (or buffer-file-name (buffer-name))))) - (when (string-match "\\.tpl\\.php\\'" (or buffer-file-name (buffer-name))) - (setq extension "tpl\\.php")) - (add-to-list 'flymake-allowed-file-name-masks - `(,(concat "\\." extension "\\'") flymake-phpcs-init))) + (setq flymake-allowed-file-name-masks '(("." drupal/flymake-phpcs-init))) (flymake-mode 1)))) +(defun drupal/flymake-phpcs-init () + (let* ((temp-file (flymake-init-create-temp-buffer-copy + (if (and (fboundp 'flymake-create-temp-intemp) + (not flymake-run-in-place)) + 'drupal/flymake-phpcs-create-temp-intemp + 'drupal/flymake-phpcs-create-temp-inplace))) + (local-file (file-relative-name temp-file + (file-name-directory buffer-file-name)))) + (list flymake-phpcs-command + (append + (list local-file) + (if flymake-phpcs-standard + (list (concat "--standard=" + ;; Looking for "/" is hardly portable + (if (string-match "/" flymake-phpcs-standard) + (expand-file-name flymake-phpcs-standard) + flymake-phpcs-standard)))) + (if flymake-phpcs-show-rule (list "-s")))))) + +(defun drupal/flymake-phpcs-create-temp-inplace (file-name &optional prefix) + "Return filename in the same directory as FILE-NAME for a +temporary copy of the buffer editing FILE-NAME. + +Note that this function, despite its name, does not actually create a +copy of the file: it only choses and returns a filename for the temp +copy." + (unless (stringp file-name) + (error "Invalid file-name")) + (or prefix + (setq prefix "flymake")) + (let* ((extension (if (string-match "\\.tpl\\.php\\'" (or buffer-file-name (buffer-name))) + ".tpl.php" + (file-name-extension file-name t))) + (base-name (replace-regexp-in-string (concat (regexp-quote extension) "\\'") "" file-name)) + (temp-name (file-truename (concat base-name "." prefix extension)))) + (flymake-log 3 "create-temp-inplace: file=%s temp=%s" file-name temp-name) + temp-name)) + +(defun drupal/flymake-phpcs-create-temp-intemp (file-name &optional prefix) + "Return filename in temporary directory for a temporary +copy of the buffer editing FILE-NAME. This is a replacement for +`flymake-create-temp-inplace'. The difference is that it gives +a file name in `temporary-file-directory' instead of the same +directory as FILE-NAME. + +For the use of PREFIX see that function. + +Note that not making the temporary file in another directory +\(like here) will not work if the file you are checking depends +relative paths to other files \(for the type of checks flymake +makes). + +Note that this function, despite its name, does not actually create a +copy of the file: it only choses and returns a filename for the temp +copy." + (unless (stringp file-name) + (error "Invalid file-name")) + (or prefix + (setq prefix "flymake")) + (let* ((extension (if (string-match "\\.tpl\\.php\\'" (or buffer-file-name (buffer-name))) + ".tpl.php" + (file-name-extension file-name t))) + (base-name (file-name-nondirectory (replace-regexp-in-string (concat (regexp-quote extension) "\\'") "" file-name))) + (temp-name (file-truename (make-temp-file (concat base-name "." prefix) nil extension)))) + (flymake-log 3 "create-temp-intemp: file=%s temp=%s" file-name temp-name) + temp-name)) + (add-hook 'drupal-mode-hook #'drupal/flymake-phpcs-enable) From 230e579786bbd5518ee99b82d8a5a1151a9c2c53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Thu, 16 Jan 2014 14:43:13 +0100 Subject: [PATCH 20/29] Removed flymake-phpcs from `drush-make-mode' files. --- drupal/flymake-phpcs.el | 1 + 1 file changed, 1 insertion(+) diff --git a/drupal/flymake-phpcs.el b/drupal/flymake-phpcs.el index 0aa073c..8ace702 100644 --- a/drupal/flymake-phpcs.el +++ b/drupal/flymake-phpcs.el @@ -62,6 +62,7 @@ file (and thus on the remote machine), or in the same place as (defun drupal/flymake-phpcs-enable () "Enable drupal-mode support for flymake-phpcs."(interactive) (when (and (apply 'derived-mode-p (append drupal-php-modes drupal-css-modes drupal-js-modes drupal-info-modes)) + (not (derived-mode-p 'drush-make-mode)) (executable-find flymake-phpcs-command) drupal/phpcs-standard) ;; Set the coding standard to "Drupal" (we checked that it is From 65efa5b78a1e88749a30e7e6533c0faace5a2789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Wed, 29 Jan 2014 13:23:36 +0100 Subject: [PATCH 21/29] 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 bd9d558..b085286 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 From 5d4558342b8a2f630d7ba20486cde37552cec113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Wed, 29 Jan 2014 13:31:32 +0100 Subject: [PATCH 22/29] Added better paragraph filling. Text fills better around Doxygen @param et al. and text in comments now do auto-fill. Fixes #5. --- drupal-mode.el | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/drupal-mode.el b/drupal-mode.el index b085286..2c84391 100644 --- a/drupal-mode.el +++ b/drupal-mode.el @@ -163,6 +163,36 @@ Include path to the executable if it is not in your $PATH." :type '(repeat symbol) :group 'drupal) +(defcustom drupal-enable-auto-fill-mode t + "Whether to use `auto-fill-mode' Drupal PHP buffers. +Drupal mode will only do auto fill in comments (auto filling code +is not nice). + +If `Yes' enable `auto-fill-mode' in Drupal PHP mode buffers. +If `No' don't enable `auto-fill-mode' in Drupal PHP mode buffers (`auto-fill-mode' can still be enabled by other settings)." + :type `(choice + :tag "Enable `auto-fill-mode'." + (const :tag "Yes" t) + (const :tag "No" nil)) + :link '(variable-link comment-auto-fill-only-comments) + :group 'drupal) + +(defcustom drupal-paragraph-separate "^[ \t]*\\(\\(/[/\\*]+\\)\\|\\(\\*+/\\)\\|\\(\\*?\\)\\|\\(\\*?[ \t]*@[[:alpha:]]+\\([ \t]+.*\\)?\\)\\)[ \t]*$" + "Regexp for beginning of a line that separates paragraphs. +In Drupal mode we extend the regular `paragraph-separate' so we +will get better filling in Doxygen comments." + :type 'regexp + :link '(variable-link paragraph-separate) + :group 'drupal) + +(defcustom drupal-paragraph-start (default-value 'drupal-paragraph-separate) + "Regexp for beginning of a line that starts OR separates paragraphs. +In Drupal mode we extend the regular `paragraph-start' so we will +get better filling in Doxygen comments." + :type 'regexp + :link '(variable-link paragraph-start) + :group 'drupal) + (defvar drupal-version nil "Drupal version as auto detected.") @@ -273,7 +303,16 @@ function arguments.") ;; Setup cc-mode style stuff. (when (derived-mode-p 'c-mode) (c-add-language 'drupal-mode 'c-mode) - (c-set-style "drupal")))) + (c-set-style "drupal")) + + ;; Use `auto-fill' only in comments. + (when drupal-enable-auto-fill-mode + (set (make-local-variable 'comment-auto-fill-only-comments) t) + (auto-fill-mode 1)) + + ;; Improve filling in Doxygen comments. + (set (make-local-variable 'paragraph-separate) drupal-paragraph-separate) + (set (make-local-variable 'paragraph-start) drupal-paragraph-start))) From 8d2c52c821e80d0c09e9ac25373b56db794dffd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Wed, 29 Jan 2014 13:33:45 +0100 Subject: [PATCH 23/29] Prepared for .api.php CoderSniffer sniffs. --- drupal/flymake-phpcs.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drupal/flymake-phpcs.el b/drupal/flymake-phpcs.el index 8ace702..e30e7e9 100644 --- a/drupal/flymake-phpcs.el +++ b/drupal/flymake-phpcs.el @@ -151,8 +151,8 @@ copy." (error "Invalid file-name")) (or prefix (setq prefix "flymake")) - (let* ((extension (if (string-match "\\.tpl\\.php\\'" (or buffer-file-name (buffer-name))) - ".tpl.php" + (let* ((extension (if (string-match "\\.\\(api\\|tpl\\)\\.php\\'" (or buffer-file-name (buffer-name))) + (match-string-no-properties 0) (file-name-extension file-name t))) (base-name (file-name-nondirectory (replace-regexp-in-string (concat (regexp-quote extension) "\\'") "" file-name))) (temp-name (file-truename (make-temp-file (concat base-name "." prefix) nil extension)))) From cd07abb5446e20ff79082e822d2c464b866fb2f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Wed, 29 Jan 2014 13:39:27 +0100 Subject: [PATCH 24/29] Made it possible to refer to issue comments. The convention to put issue numbers in brackets at patches and have the issue number be a clickable link, i.e: projects[ctools][patch][1277908] = http://drupal.org/files/ctools-uuids_for_exported_objects-1277908-118.patch is extended so we can have add i.e comment numbers and still have them clickable, i.e.: projects[services][patch]['1912842-9'] = http://drupal.org/files/services-rest_server_parse_xml_with_arrays-1912842-9.patch projects[services][patch]['1912842-13'] = http://drupal.org/files/issues/services-rest_server_parse_xml_with_arrays-1912842 --- drush-make-mode.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drush-make-mode.el b/drush-make-mode.el index 2ccf22d..8c8bd5e 100644 --- a/drush-make-mode.el +++ b/drush-make-mode.el @@ -1,6 +1,6 @@ ;;; drush-make-mode.el --- Major mode for drush make files -;; Copyright (C) 2013 Arne Jørgensen +;; Copyright (C) 2013, 2014 Arne Jørgensen ;; Author: Arne Jørgensen ;; Keywords: languages, tools, extensions @@ -35,7 +35,7 @@ ;; Use `bug-reference-mode' for linking issues and patches. (set (make-local-variable 'bug-reference-url-format) "http://drupal.org/node/%s") - (set (make-local-variable 'bug-reference-bug-regexp) "\\(?:\\#\\(?2:[0-9]+\\)\\|\\[['\"]?\\(?2:[0-9]+\\)\\(['\"]?\\]\\)\\)") + (set (make-local-variable 'bug-reference-bug-regexp) "\\(?:\\#\\(?2:[0-9]+\\)\\|\\[['\"]?\\(?2:[0-9]+\\)\\([^0-9].*\\)?\\(['\"]?\\]\\)\\)") (bug-reference-mode) ;; Use `goto-address-mode' for link highlighting. From 1a73416e786c745ba39ef058e48810b007956abc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Wed, 29 Jan 2014 22:16:42 +0100 Subject: [PATCH 25/29] Fixed flymake when real file is in a symlinked dir. Fixes #14. --- drupal/flymake-phpcs.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drupal/flymake-phpcs.el b/drupal/flymake-phpcs.el index e30e7e9..f89d50f 100644 --- a/drupal/flymake-phpcs.el +++ b/drupal/flymake-phpcs.el @@ -99,7 +99,7 @@ file (and thus on the remote machine), or in the same place as 'drupal/flymake-phpcs-create-temp-intemp 'drupal/flymake-phpcs-create-temp-inplace))) (local-file (file-relative-name temp-file - (file-name-directory buffer-file-name)))) + (file-name-directory (file-truename buffer-file-name))))) (list flymake-phpcs-command (append (list local-file) From 7ddadecabd1c052df0490c950aca522a275f1d7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Thu, 20 Feb 2014 21:51:59 +0100 Subject: [PATCH 26/29] Reduced number of times calling `drupal-detect-drupal-version`. --- drupal-mode.el | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drupal-mode.el b/drupal-mode.el index 2c84391..f89ec53 100644 --- a/drupal-mode.el +++ b/drupal-mode.el @@ -268,9 +268,6 @@ function arguments.") :lighter " Drupal" :keymap drupal-mode-map - ;; Detect drupal version, drupal root, etc. - (drupal-detect-drupal-version) - ;; Delete trailing white space. (when (eq drupal-delete-trailing-whitespace 'always) (add-hook 'before-save-hook #'delete-trailing-whitespace nil t)) @@ -546,7 +543,7 @@ It is really slow to download `drupal-search-url'. You should probably not use this. Have a look at using GNU GLOBAL / Gtags instead." (unless version - (setq version (drupal-detect-drupal-version))) + (setq version drupal-version)) (with-temp-buffer (ignore-errors (url-insert-file-contents (format-spec drupal-search-url `((?v . ,version) @@ -740,7 +737,7 @@ Used in `drupal-insert-hook' and `drupal-insert-function'." "Return major version number of version string. If major version number is 4 - return both major and minor." (unless version - (setq version (drupal-detect-drupal-version))) + (setq version drupal-version)) (when version (let ((version-list (split-string version "\\."))) (if (= (string-to-number (car version-list)) 4) From 03b7e28b8ddd4ebd47a0e0d4d8cff5a7195214ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Fri, 21 Feb 2014 20:58:32 +0100 Subject: [PATCH 27/29] Fixed bad indentation. --- drupal/flymake-phpcs.el | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drupal/flymake-phpcs.el b/drupal/flymake-phpcs.el index f89d50f..a6c6cfc 100644 --- a/drupal/flymake-phpcs.el +++ b/drupal/flymake-phpcs.el @@ -60,7 +60,8 @@ file (and thus on the remote machine), or in the same place as :group 'drupal)) (defun drupal/flymake-phpcs-enable () - "Enable drupal-mode support for flymake-phpcs."(interactive) + "Enable drupal-mode support for flymake-phpcs." + (interactive) (when (and (apply 'derived-mode-p (append drupal-php-modes drupal-css-modes drupal-js-modes drupal-info-modes)) (not (derived-mode-p 'drush-make-mode)) (executable-find flymake-phpcs-command) From 4532cd72177649ebb8a206f2b71812b8588aa23b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Fri, 21 Feb 2014 21:00:32 +0100 Subject: [PATCH 28/29] Use `._flymake` as temp file pattern. Use a mix up of the standard `_flymake` and starting the pattern with `.` to play with my patch to [CoderSniffer](https://drupal.org/node/2172383). --- drupal/flymake-phpcs.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drupal/flymake-phpcs.el b/drupal/flymake-phpcs.el index a6c6cfc..d0d881a 100644 --- a/drupal/flymake-phpcs.el +++ b/drupal/flymake-phpcs.el @@ -127,7 +127,7 @@ copy." ".tpl.php" (file-name-extension file-name t))) (base-name (replace-regexp-in-string (concat (regexp-quote extension) "\\'") "" file-name)) - (temp-name (file-truename (concat base-name "." prefix extension)))) + (temp-name (file-truename (concat base-name "._" prefix extension)))) (flymake-log 3 "create-temp-inplace: file=%s temp=%s" file-name temp-name) temp-name)) @@ -156,7 +156,7 @@ copy." (match-string-no-properties 0) (file-name-extension file-name t))) (base-name (file-name-nondirectory (replace-regexp-in-string (concat (regexp-quote extension) "\\'") "" file-name))) - (temp-name (file-truename (make-temp-file (concat base-name "." prefix) nil extension)))) + (temp-name (file-truename (make-temp-file (concat base-name "._" prefix) nil extension)))) (flymake-log 3 "create-temp-intemp: file=%s temp=%s" file-name temp-name) temp-name)) From 95d6ecdd75d0df3017ec215a32f1f5a4603de76c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arne=20J=C3=B8rgensen?= Date: Fri, 21 Feb 2014 21:56:39 +0100 Subject: [PATCH 29/29] Bumped version number. --- drupal-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drupal-mode.el b/drupal-mode.el index f89ec53..c8cb7a8 100644 --- a/drupal-mode.el +++ b/drupal-mode.el @@ -5,7 +5,7 @@ ;; Author: Arne Jørgensen ;; URL: https://github.com/arnested/drupal-mode ;; Created: January 17, 2012 -;; Version: 0.4.0 +;; Version: 0.4.1 ;; Package-Requires: ((php-mode "1.5.0")) ;; Keywords: programming, php, drupal