Skip to content

Commit 8466fef

Browse files
committed
Fix flycheck to use 'source instead of 'source-inplace
1 parent f17e8ae commit 8466fef

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

flycheck-eldev.el

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,20 @@ If FROM is nil, search from `default-directory'."
199199
(defun flycheck-eldev--working-directory (&rest _)
200200
(flycheck-eldev-find-root))
201201

202+
(defun flycheck-eldev--checker-substituted-arguments (checker)
203+
"Get the substituted arguments of a CHECKER.
204+
205+
Wrapper for `flycheck-checker-substituted-arguments' which replaces
206+
\='source-inplace with \='source.
207+
208+
CHECKER is passed to `flycheck-checker-substituted-arguments'."
209+
(apply #'append
210+
(seq-map (lambda (arg)
211+
(when (eq arg 'source-inplace)
212+
(setq arg 'source))
213+
(flycheck-substitute-argument arg checker))
214+
(flycheck-checker-arguments checker))))
215+
202216
(defun flycheck-eldev--build-command-line ()
203217
`("--quiet" "--no-time" "--color=never" "--no-debug" "--no-backtrace-on-abort"
204218
,@(if (flycheck-eldev-project-trusted-p default-directory)
@@ -208,7 +222,7 @@ If FROM is nil, search from `default-directory'."
208222
;; future improvements for free.
209223
(let* ((super (let ((flycheck-emacs-lisp-load-path nil)
210224
(flycheck-emacs-lisp-initialize-packages nil))
211-
(flycheck-checker-substituted-arguments 'emacs-lisp)))
225+
(flycheck-eldev--checker-substituted-arguments 'emacs-lisp)))
212226
(head (-drop-last 2 super))
213227
(tail (-take-last 2 super))
214228
(filename (cadr tail))
@@ -242,7 +256,10 @@ If FROM is nil, search from `default-directory'."
242256
(eldev-advised
243257
(#'insert-file-contents
244258
:around (lambda (original filename &rest arguments)
245-
(unless (file-equal-p filename ,real-filename)
259+
(if (file-equal-p filename ,real-filename)
260+
;; Load the temp file
261+
;; instead.
262+
(apply original ,filename arguments)
246263
(apply original filename arguments))))
247264
(funcall original)))))
248265
;; When checking project's main file, use the temporary as the main file

0 commit comments

Comments
 (0)