Skip to content

Commit bcf7a8b

Browse files
committed
Introduce an auto option for drupal/flymake-phpcs-run-in-place
`Auto` will do a `run-in-place` on .info files and in `tempdir` on everything else. That should make Drupal Coder Sniffer do the right thing with current rules: - constants will be checked with the right module name. - files[] entries in .info files will be checked against th actual files.
1 parent 2e51a20 commit bcf7a8b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drupal/flymake-phpcs.el

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
;; https://github.com/illusori/emacs-flymake.
4040
(when (or (boundp 'flymake-run-in-place)
4141
(fboundp 'flymake-phpcs-load))
42-
(defcustom drupal/flymake-phpcs-run-in-place t
42+
(defcustom drupal/flymake-phpcs-run-in-place 'auto
4343
"If nil, flymake will run on copies in `temporary-file-directory' rather
4444
than the same directory as the original file.
4545
@@ -55,6 +55,7 @@ file (and thus on the remote machine), or in the same place as
5555
:type `(choice
5656
(const :tag "Yes" t)
5757
(const :tag "No" nil)
58+
(const :tag "Auto" auto)
5859
(const :tag "Default" default))
5960
:link '(url-link :tag "Drupal Coder Sniffer" "https://drupal.org/project/coder")
6061
:group 'drupal))
@@ -77,7 +78,10 @@ file (and thus on the remote machine), or in the same place as
7778
(if drupal/flymake-phpcs-run-in-place
7879
(set (make-local-variable 'flymake-phpcs-location) 'inplace)
7980
(set (make-local-variable 'flymake-phpcs-location) 'tempdir)))
80-
(set (make-local-variable 'flymake-run-in-place) drupal/flymake-phpcs-run-in-place))
81+
(if (and (eq drupal/flymake-phpcs-run-in-place 'auto)
82+
(string-match "\\.info\\'" (or buffer-file-name (buffer-name))))
83+
(set (make-local-variable 'flymake-run-in-place) t)
84+
(set (make-local-variable 'flymake-run-in-place) nil)))
8185

8286
;; Flymake-phpcs will also highlight trailing whitespace as an
8387
;; error so no need to highlight it twice.
@@ -156,7 +160,8 @@ copy."
156160
(match-string-no-properties 0)
157161
(file-name-extension file-name t)))
158162
(base-name (file-name-nondirectory (replace-regexp-in-string (concat (regexp-quote extension) "\\'") "" file-name)))
159-
(temp-name (file-truename (make-temp-file (concat base-name "._" prefix) nil extension))))
163+
(temp-dir (file-truename (make-temp-file base-name t nil)))
164+
(temp-name (file-truename (concat temp-dir "/" file-name))))
160165
(flymake-log 3 "create-temp-intemp: file=%s temp=%s" file-name temp-name)
161166
temp-name))
162167

0 commit comments

Comments
 (0)