aboutsummaryrefslogtreecommitdiff
path: root/apheleia-formatters.el
diff options
context:
space:
mode:
authorRadon Rosborough <radon@intuitiveexplanations.com>2024-09-25 19:28:33 -0700
committerGitHub <noreply@github.com>2024-09-25 19:28:33 -0700
commit302a41c86c5ffe1e8f50cbe156e0f7b21835c02c (patch)
tree3288feb6701e069e967148b079ad0a5a5369d71d /apheleia-formatters.el
parent9343b86f7c6c51866bb9e682dbc9c3233748aecc (diff)
Use --stdin-filename conditionally for mix-format (#322)
Closes #319 because this does the same thing but it transparently works for all versions of mix-format.
Diffstat (limited to 'apheleia-formatters.el')
-rw-r--r--apheleia-formatters.el29
1 files changed, 17 insertions, 12 deletions
diff --git a/apheleia-formatters.el b/apheleia-formatters.el
index 2446d12..ec3d83b 100644
--- a/apheleia-formatters.el
+++ b/apheleia-formatters.el
@@ -91,7 +91,7 @@
(ktlint . ("ktlint" "--log-level=none" "--stdin" "-F" "-"))
(latexindent . ("latexindent" "--logfile=/dev/null"))
(mix-format . ("apheleia-from-project-root"
- ".formatter.exs" "mix" "format" "-"))
+ ".formatter.exs" "apheleia-mix-format" filepath))
(nixfmt . ("nixfmt"))
(ocamlformat . ("ocamlformat" "-" "--name" filepath
"--enable-outside-detected-project"))
@@ -1063,17 +1063,22 @@ purposes."
;; resolve for the whole formatting process (for example
;; `apheleia--current-process').
(with-current-buffer buffer
- (when-let ((exec-path
- (append `(,(expand-file-name
- "scripts/formatters"
- (file-name-directory
- (file-truename
- ;; Borrowed with love from Magit
- (let ((load-suffixes '(".el")))
- (locate-library "apheleia"))))))
- exec-path))
- (ctx
- (apheleia--formatter-context formatter command remote stdin)))
+ (when-let* ((script-dir (expand-file-name
+ "scripts/formatters"
+ (file-name-directory
+ (file-truename
+ ;; Borrowed with love from Magit
+ (let ((load-suffixes '(".el")))
+ (locate-library "apheleia"))))))
+ ;; Gotta set both `exec-path' and the PATH env-var,
+ ;; the former is for Emacs itself while the latter is
+ ;; for subprocesses of the proc we start.
+ (exec-path (cons script-dir exec-path))
+ (process-environment
+ (cons (concat "PATH=" script-dir ":" (getenv "PATH"))
+ process-environment))
+ (ctx
+ (apheleia--formatter-context formatter command remote stdin)))
(if (executable-find (apheleia-formatter--arg1 ctx)
(eq apheleia-remote-algorithm 'remote))
(apheleia--execute-formatter-process