Skip to content

Commit a25b4df

Browse files
committed
Cope with different implementations of flymake-phpcs.
1 parent a4768c7 commit a25b4df

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

drupal/flymake-phpcs.el

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434

3535
;; Only available when `flymake' is the fork from
3636
;; https://github.com/illusori/emacs-flymake.
37-
(when (boundp 'flymake-run-in-place)
37+
(when (or (boundp 'flymake-run-in-place)
38+
(fboundp 'flymake-phpcs-load))
3839
(defcustom drupal/flymake-phpcs-run-in-place t
3940
"If nil, flymake will run on copies in `temporary-file-directory' rather
4041
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
6162
(executable-find flymake-phpcs-command)
6263
drupal/phpcs-standard)
6364
;; Set the coding standard to "Drupal" (we checked that it is
64-
;; supported above.
65+
;; supported above).
6566
(set (make-local-variable 'flymake-phpcs-standard) drupal/phpcs-standard)
6667

6768
;; Set whether flymake runs in place.
6869
(when (and (boundp 'drupal/flymake-phpcs-run-in-place)
6970
(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)))
7075
(set (make-local-variable 'flymake-run-in-place) drupal/flymake-phpcs-run-in-place))
7176

7277
;; 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
7681
;; This is a php-mode file so add the extension to a buffer locale
7782
;; version of `flymake-allowed-file-name-masks' and make
7883
;; flymake-phpcs initialize.
79-
(make-local-variable 'flymake-allowed-file-name-masks)
80-
(let ((extension (file-name-extension (or buffer-file-name (buffer-name)))))
81-
(when (string-match "\\.tpl\\.php\\'" (or buffer-file-name (buffer-name)))
82-
(setq extension "tpl\\.php"))
83-
(add-to-list 'flymake-allowed-file-name-masks
84-
`(,(concat "\\." extension "\\'") flymake-phpcs-init)))
85-
(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))))
8693

8794
(add-hook 'drupal-mode-hook #'drupal/flymake-phpcs-enable)
8895

0 commit comments

Comments
 (0)