branch: elpa/drupal-mode
commit a25b4df69a8c23920cada4392901ff07ae6e7d21
Author: Arne Jørgensen <[email protected]>
Commit: Arne Jørgensen <[email protected]>
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 3b285b57c9..65bb429b89 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)