Skip to content

Commit f1985b5

Browse files
committed
Merge branch 'release/0.4.0'
2 parents a08207b + b2ba37e commit f1985b5

File tree

9 files changed

+101
-47
lines changed

9 files changed

+101
-47
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
CASK?=cask
2323
EMACS?=emacs
24-
TAR?=bsdtar
24+
TAR?=COPYFILE_DISABLE=1 bsdtar
2525
PANDOC?=pandoc --atx-headers
2626

2727
VERSION?=$(shell $(CASK) version)
@@ -46,7 +46,7 @@ $(ARCHIVE_NAME)-pkg.el: $(ARCHIVE_NAME).el
4646

4747
# create a tar ball in package.el format for uploading to http://marmalade-repo.org
4848
$(PACKAGE_NAME).tar: README $(ARCHIVE_NAME).el $(ARCHIVE_NAME)-pkg.el $(ARCHIVE_NAME).info dir drupal/*.el drupal-tests.el drush-make-mode.el
49-
COPYFILE_DISABLE=1 $(TAR) -c -s "@^@$(PACKAGE_NAME)/@" -f $(PACKAGE_NAME).tar $^
49+
$(TAR) -c -s "@^@$(PACKAGE_NAME)/@" -f $(PACKAGE_NAME).tar $^
5050

5151
install: $(PACKAGE_NAME).tar
5252
$(EMACS) --batch -l package -f package-initialize --eval "(package-install-file \"$(PWD)/$(PACKAGE_NAME).tar\")"

drupal-mode.el

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
;;; drupal-mode.el --- Advanced minor mode for Drupal development
22

3-
;; Copyright (C) 2012, 2013 Arne Jørgensen
3+
;; Copyright (C) 2012, 2013, 2014 Arne Jørgensen
44

55
;; Author: Arne Jørgensen <[email protected]>
66
;; URL: https://github.com/arnested/drupal-mode
77
;; Created: January 17, 2012
8-
;; Version: 0.3.1
8+
;; Version: 0.4.0
99
;; Package-Requires: ((php-mode "1.5.0"))
1010
;; Keywords: programming, php, drupal
1111

@@ -36,7 +36,7 @@
3636
(require 'php-mode)
3737
(require 'format-spec)
3838

39-
(eval-when-compile
39+
(eval-when-compile
4040
(require 'css-mode))
4141

4242

@@ -62,7 +62,7 @@ If `Ask' ask the user whether to convert line endings.
6262
6363
Drupal coding standards states that all text files should end in
6464
a single newline (\\n)."
65-
:type `(choice
65+
:type `(choice
6666
:tag " we offer to change line endings if needed?"
6767
(const :tag "Always" t)
6868
(const :tag "Never" nil)
@@ -83,7 +83,7 @@ If `Default' do what the global setting is.
8383
8484
Drupal coding standards states that lines should have no trailing
8585
whitespace at the end."
86-
:type `(choice
86+
:type `(choice
8787
:tag "Whether to delete all the trailing whitespace."
8888
(const :tag "Always" always)
8989
(const :tag "Default" default)
@@ -98,6 +98,7 @@ whitespace at the end."
9898
%s is the search term."
9999
:type '(choice (const :tag "Api.drupal.org" "http://api.drupal.org/api/search/%v/%s")
100100
(const :tag "Api.drupalcontrib.org" "http://api.drupalcontrib.org/api/search/%v/%s")
101+
(const :tag "Api.drupalize.me" "http://api.drupalize.me/api/search/%v/%s")
101102
(string :tag "Other" "http://example.com/api/search/%v/%s"))
102103
:link '(url-link :tag "api.drupalcontrib.org" "http://api.drupalcontrib.org")
103104
:link '(url-link :tag "api.drupal.org" "http://api.drupal.org")
@@ -188,14 +189,23 @@ Include path to the executable if it is not in your $PATH."
188189
(make-variable-buffer-local 'drupal-project)
189190
(put 'drupal-project 'safe-local-variable 'string-or-null-p)
190191

192+
(defvar drupal-mode-map-alist
193+
'((?d . drupal-search-documentation)
194+
(?c . drupal-drush-cache-clear)
195+
(?h . drupal-insert-hook)
196+
(?f . drupal-insert-function)
197+
(?m . drupal-module-name)
198+
(?t . drupal-wrap-string-in-t-function))
199+
"Map of mnemonic keys and functions for keyboard shortcuts.
200+
See `drupal-mode-map'.")
201+
191202
(defvar drupal-mode-map
192203
(let ((map (make-sparse-keymap)))
193-
(define-key map [(control c) (control v) (control d)] #'drupal-search-documentation)
194-
(define-key map [(control c) (control v) (control c)] #'drupal-drush-cache-clear)
195-
(define-key map [(control c) (control v) (control h)] #'drupal-insert-hook)
196-
(define-key map [(control c) (control v) (control f)] #'drupal-insert-function)
197-
(define-key map [(control c) (control v) (control m)] #'drupal-module-name)
198-
(define-key map [(control c) (control v) (control t)] #'drupal-wrap-string-in-t-function)
204+
;; Iterate `drupal-mode-map-alist' and assign the functions to the
205+
;; mode map on C-c C-v C-`mnemonic-key'.
206+
(dolist (elem drupal-mode-map-alist)
207+
(define-key map `[(control c) (control v) (control ,(car elem))] (cdr elem)))
208+
199209
(define-key map [(control a)] #'drupal-mode-beginning-of-line)
200210
map)
201211
"Keymap for `drupal-mode'")
@@ -538,12 +548,12 @@ Heavily based on `message-beginning-of-line' from Gnus."
538548
(set zrs t)))
539549
(if (derived-mode-p 'conf-mode)
540550
(let* ((here (point))
541-
(bol (progn (beginning-of-line n) (point)))
542-
(eol (point-at-eol))
543-
(eoh (re-search-forward "= *" eol t)))
544-
(goto-char
545-
(if (and eoh (or (< eoh here) (= bol here)))
546-
eoh bol)))
551+
(bol (progn (beginning-of-line n) (point)))
552+
(eol (point-at-eol))
553+
(eoh (re-search-forward "= *" eol t)))
554+
(goto-char
555+
(if (and eoh (or (< eoh here) (= bol here)))
556+
eoh bol)))
547557
(beginning-of-line n)))
548558

549559

@@ -666,7 +676,7 @@ Used in `drupal-insert-hook' and `drupal-insert-function'."
666676
drupal-module
667677
;; Otherwise fall back to a very naive
668678
;; way of guessing the module name.
669-
(file-name-nondirectory (file-name-sans-extension (buffer-file-name)))))))
679+
(file-name-nondirectory (file-name-sans-extension (or buffer-file-name (buffer-name))))))))
670680
(if (called-interactively-p 'any)
671681
(insert name)
672682
name)))

drupal/autoinsert.el

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
;;; drupal/autoinsert.el --- Drupal-mode support for `auto-insert-mode'
22

3-
;; Copyright (C) 2012, 2013 Arne Jørgensen
3+
;; Copyright (C) 2012, 2013, 2014 Arne Jørgensen
44

55
;; Author: Arne Jørgensen <[email protected]>
6-
;; Keywords:
6+
;; Keywords:
77

88
;; This file is part of Drupal mode.
99

@@ -34,7 +34,7 @@
3434
(define-skeleton drupal/autoinsert-insert-info-skeleton
3535
"Drupal info file skeleton."
3636
nil
37-
'(setq v1 (file-name-nondirectory (file-name-sans-extension (buffer-file-name))))
37+
'(setq v1 (file-name-nondirectory (file-name-sans-extension (or buffer-file-name (buffer-name)))))
3838
'(setq v2 (if (drupal-major-version) (>= (string-to-number (drupal-major-version)) 7) t))
3939
"name = " @ - (upcase-initials (replace-regexp-in-string "[-_\\.]+" " " v1)) \n
4040
"description = " @ \n

drupal/emacs-drush.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
On `after-save-hook' run `drush etags' or `drush gtags'.
3939
4040
Requires `Drush utilities for Emacs users' to be installed."
41-
:type `(choice
41+
:type `(choice
4242
(const :tag "Yes" t)
4343
(const :tag "No" nil))
4444
:link '(url-link :tag "Drush utilities for Emacs users" "https://drupal.org/project/emacs_drush")

drupal/etags.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
;;; drupal/etags.el --- Drupal-mode support for etags
22

3-
;; Copyright (C) 2012, 2013 Arne Jørgensen
3+
;; Copyright (C) 2012, 2013, 2014 Arne Jørgensen
44

55
;; Author: Arne Jørgensen <[email protected]>
66

@@ -29,7 +29,7 @@
2929

3030
(defun drupal/etags-enable ()
3131
"Setup TAGS file for etags if it exists."
32-
(let ((dir (locate-dominating-file (buffer-file-name) "TAGS")))
32+
(let ((dir (locate-dominating-file (or buffer-file-name default-directory) "TAGS")))
3333
(when dir
3434
(set (make-local-variable 'drupal/etags-rootdir) dir)
3535

drupal/flycheck.el

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
;;; drupal/flycheck.el --- Drupal-mode support for flycheck and phpcs
22

3-
;; Copyright (C) 2012, 2013 Arne Jørgensen
3+
;; Copyright (C) 2012, 2013, 2014 Arne Jørgensen
44

55
;; Author: Thomas Fini Hansen <[email protected]>
66

@@ -25,6 +25,9 @@
2525

2626
;;; Code:
2727

28+
(eval-when-compile
29+
(require 'flycheck))
30+
2831
(require 'drupal/phpcs)
2932

3033
(defcustom drupal/flycheck-phpcs-js-and-css t
@@ -48,27 +51,32 @@
4851

4952
(add-hook 'drupal-mode-hook #'drupal/flycheck-hook)
5053

51-
(flycheck-declare-checker css-js-phpcs
54+
(flycheck-define-checker css-js-phpcs
5255
"Check CSS and JavaScript using PHP_CodeSniffer.
5356
5457
PHP_CodeSniffer can be used to check non-PHP files, as exemplified by the
5558
Drupal code sniffer.
5659
5760
See URL `http://pear.php.net/package/PHP_CodeSniffer/'."
58-
:command '("phpcs" "--report=emacs"
59-
(option "--standard=" flycheck-phpcs-standard)
60-
source)
61+
:command ("phpcs" "--report=emacs"
62+
(option "--standard=" flycheck-phpcs-standard)
63+
source)
6164
;; Though phpcs supports Checkstyle output which we could feed to
6265
;; `flycheck-parse-checkstyle', we are still using error patterns here,
6366
;; because PHP has notoriously unstable output habits. See URL
6467
;; `https://github.com/lunaryorn/flycheck/issues/78' and URL
6568
;; `https://github.com/lunaryorn/flycheck/issues/118'
6669
:error-patterns
67-
'(("\\(?1:.*\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\): error - \\(?4:.*\\)" error)
68-
("\\(?1:.*\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\): warning - \\(?4:.*\\)" warning))
69-
:modes '(css-mode js-mode)
70+
((error line-start
71+
(file-name) ":" line ":" column ": error - " (message)
72+
line-end)
73+
(warning line-start
74+
(file-name) ":" line ":" column ": warning - " (message)
75+
line-end))
76+
:modes (css-mode js-mode)
7077
:predicate (lambda ()
7178
(and drupal/flycheck-phpcs-js-and-css (apply 'derived-mode-p (append drupal-php-modes drupal-css-modes drupal-js-modes)))))
79+
7280
(add-to-list 'flycheck-checkers 'css-js-phpcs)
7381

7482

drupal/flymake-phpcs.el

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
;;; drupal/flymake-phpcs.el --- Drupal-mode support for flymake-phpcs
22

3-
;; Copyright (C) 2012, 2013 Arne Jørgensen
3+
;; Copyright (C) 2012, 2013, 2014 Arne Jørgensen
44

55
;; Author: Arne Jørgensen <[email protected]>
66

@@ -32,26 +32,64 @@
3232
(define-obsolete-variable-alias 'drupal/flymake-phpcs-dont-show-trailing-whitespace 'drupal/phpcs-dont-show-trailing-whitespace)
3333
(require 'drupal/phpcs)
3434

35+
;; Only available when `flymake' is the fork from
36+
;; https://github.com/illusori/emacs-flymake.
37+
(when (or (boundp 'flymake-run-in-place)
38+
(fboundp 'flymake-phpcs-load))
39+
(defcustom drupal/flymake-phpcs-run-in-place t
40+
"If nil, flymake will run on copies in `temporary-file-directory' rather
41+
than the same directory as the original file.
42+
43+
Drupal Coder Sniffer has some sniffs that will only work if run in place.
44+
45+
Defaults to `t'. Set to `default' to use whatever
46+
`flymake-run-in-place' is set to.
47+
48+
When editing a remote file via Tramp, this flag also has the side-effect of
49+
determining whether the syntax check is run in the same place as the original
50+
file (and thus on the remote machine), or in the same place as
51+
`temporary-file-directory' (usually the local machine)."
52+
:type `(choice
53+
(const :tag "Yes" t)
54+
(const :tag "No" nil)
55+
(const :tag "Default" default))
56+
:link '(url-link :tag "Drupal Coder Sniffer" "https://drupal.org/project/coder")
57+
:group 'drupal))
58+
3559
(defun drupal/flymake-phpcs-enable ()
36-
"Enable drupal-mode support for flymake-phpcs."
37-
(when (and (apply 'derived-mode-p (append drupal-php-modes drupal-css-modes drupal-js-modes))
60+
"Enable drupal-mode support for flymake-phpcs."(interactive)
61+
(when (and (apply 'derived-mode-p (append drupal-php-modes drupal-css-modes drupal-js-modes drupal-info-modes))
3862
(executable-find flymake-phpcs-command)
3963
drupal/phpcs-standard)
4064
;; Set the coding standard to "Drupal" (we checked that it is
41-
;; supported above.
65+
;; supported above).
4266
(set (make-local-variable 'flymake-phpcs-standard) drupal/phpcs-standard)
4367

68+
;; Set whether flymake runs in place.
69+
(when (and (boundp 'drupal/flymake-phpcs-run-in-place)
70+
(not (eq drupal/flymake-phpcs-run-in-place 'default)))
71+
(when (fboundp 'flymake-phpcs-load)
72+
(if drupal/flymake-phpcs-run-in-place
73+
(set (make-local-variable 'flymake-phpcs-location) 'inplace)
74+
(set (make-local-variable 'flymake-phpcs-location) 'tempdir)))
75+
(set (make-local-variable 'flymake-run-in-place) drupal/flymake-phpcs-run-in-place))
76+
4477
;; Flymake-phpcs will also highlight trailing whitespace as an
4578
;; error so no need to highlight it twice.
4679
(drupal/phpcs-dont-show-trailing-whitespace)
4780

4881
;; This is a php-mode file so add the extension to a buffer locale
4982
;; version of `flymake-allowed-file-name-masks' and make
5083
;; flymake-phpcs initialize.
51-
(make-local-variable 'flymake-allowed-file-name-masks)
52-
(add-to-list 'flymake-allowed-file-name-masks
53-
`(,(concat "\\." (file-name-extension (or buffer-file-name (buffer-name))) "\\'") flymake-phpcs-init))
54-
(flymake-mode 1)))
84+
(if (fboundp 'flymake-phpcs-load)
85+
(flymake-phpcs-load)
86+
(make-local-variable 'flymake-allowed-file-name-masks)
87+
(let ((extension (file-name-extension (or buffer-file-name (buffer-name)))))
88+
(when (string-match "\\.tpl\\.php\\'" (or buffer-file-name (buffer-name)))
89+
(setq extension "tpl\\.php"))
90+
(add-to-list 'flymake-allowed-file-name-masks
91+
`(,(concat "\\." extension "\\'") flymake-phpcs-init)))
92+
(flymake-mode 1))))
5593

5694
(add-hook 'drupal-mode-hook #'drupal/flymake-phpcs-enable)
5795

drupal/gtags.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
;;; drupal/gtags.el --- Drupal-mode support for gtags
22

3-
;; Copyright (C) 2012, 2013 Arne Jørgensen
3+
;; Copyright (C) 2012, 2013, 2014 Arne Jørgensen
44

55
;; Author: Arne Jørgensen <[email protected]>
66

@@ -35,7 +35,7 @@ Include path to the executable if it is not in your $PATH.")
3535

3636
(defun drupal/gtags-enable ()
3737
"Setup rootdir for gtags."
38-
(let ((dir (locate-dominating-file (buffer-file-name) "GTAGS")))
38+
(let ((dir (locate-dominating-file (or buffer-file-name default-directory) "GTAGS")))
3939
(when dir
4040
(set (make-local-variable 'gtags-rootdir) dir)
4141

drupal/phpcs.el

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
;; command. Check for both.
3535
(call-process (or (and (boundp 'flymake-phpcs-command) (executable-find flymake-phpcs-command)) (executable-find "phpcs")) nil (list t nil) nil "-i")))))
3636
(when (string-match
37-
"\\(Drupal[^,
37+
"\\(Drupal[^,
3838
]*\\)"
3939
standards)
4040
(match-string-no-properties 1 standards))))
@@ -60,8 +60,6 @@ need to highlight it twice."
6060
(defun drupal/phpcs-dont-show-trailing-whitespace ()
6161
"Turn of various trailing white space highlighting."
6262
(when drupal/phpcs-dont-show-trailing-whitespace
63-
(when (boundp 'whitespace-style)
64-
(set (make-local-variable 'whitespace-style) (remove 'trailing whitespace-style)))
6563
(setq show-trailing-whitespace nil)))
6664

6765
(provide 'drupal/phpcs)

0 commit comments

Comments
 (0)