summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoão Távora <joaotavora@gmail.com>2018-11-10 12:58:08 +0000
committerJoão Távora <joaotavora@gmail.com>2018-12-04 23:34:36 +0000
commit4ef97113b24045e87ee05acb48bb2befad84d47a (patch)
treeac08b635ae6b793bff3b9ec4c4f8a53795478be1
parent12e922156c86a26fa4bb2cb9e7d2b3fd639e4707 (diff)
downloademacs-scratch/allow-custom-load-paths-in-elisp-flymake.tar.gz
Allow custom load paths in elisp's byte-compilation Flymakescratch/allow-custom-load-paths-in-elisp-flymake
* lisp/progmodes/elisp-mode.el (elisp-flymake-byte-compile-load-path): New variable. (elisp-flymake-byte-compile): Use new variable
-rw-r--r--lisp/progmodes/elisp-mode.el25
1 files changed, 18 insertions, 7 deletions
diff --git a/lisp/progmodes/elisp-mode.el b/lisp/progmodes/elisp-mode.el
index 39df9efda2c..8c9b5d2c4ac 100644
--- a/lisp/progmodes/elisp-mode.el
+++ b/lisp/progmodes/elisp-mode.el
@@ -1669,6 +1669,16 @@ Calls REPORT-FN directly."
(defvar-local elisp-flymake--byte-compile-process nil
"Buffer-local process started for byte-compiling the buffer.")
+(defvar elisp-flymake-byte-compile-load-path (list "./")
+ "Like `load-path' but used by `elisp-flymake-byte-compile'.
+The default value contains just \"./\" which includes the default
+directory of the buffer being compiled, and nothing else.")
+
+(put 'elisp-flymake-byte-compile-load-path 'safe-local-variable
+ (lambda (x) (and (listp x) (catch 'tag
+ (dolist (path x t) (unless (stringp path)
+ (throw 'tag nil)))))))
+
;;;###autoload
(defun elisp-flymake-byte-compile (report-fn &rest _args)
"A Flymake backend for elisp byte compilation.
@@ -1688,13 +1698,14 @@ current buffer state and calls REPORT-FN when done."
(make-process
:name "elisp-flymake-byte-compile"
:buffer output-buffer
- :command (list (expand-file-name invocation-name invocation-directory)
- "-Q"
- "--batch"
- ;; "--eval" "(setq load-prefer-newer t)" ; for testing
- "-L" default-directory
- "-f" "elisp-flymake--batch-compile-for-flymake"
- temp-file)
+ :command `(,(expand-file-name invocation-name invocation-directory)
+ "-Q"
+ "--batch"
+ ;; "--eval" "(setq load-prefer-newer t)" ; for testing
+ ,@(mapcan (lambda (path) (list "-L" path))
+ elisp-flymake-byte-compile-load-path)
+ "-f" "elisp-flymake--batch-compile-for-flymake"
+ ,temp-file)
:connection-type 'pipe
:sentinel
(lambda (proc _event)