aboutsummaryrefslogtreecommitdiff
path: root/apheleia.el
diff options
context:
space:
mode:
authorleonidborisenko <leonidborisenko@users.noreply.github.com>2022-10-05 23:19:36 +0000
committerGitHub <noreply@github.com>2022-10-05 23:19:36 +0000
commitaae79b7b2a1a7bc905b005ec3f43feb56918b93d (patch)
tree7063079e94cee6c88520b494e7dbdb2b04ea1fe5 /apheleia.el
parent7aa46ba84f06251f280d226f98cb06ef83a0a697 (diff)
Use inplace formatter output (#132)
When formatting command is defined with symbol `inplace`, it doesn't work. I'm using [casey/just](https://github.com/casey/just) (v1.5.0). It doesn't support formatting of `stdin`, but it supports in-place formatting with command `just --unstable --fmt --justfile /tmp/justfile`. So I've added a list to to `apheleia-formatters` custom variable: ```elisp (add-to-list 'apheleia-formatters '(just . ("just" "--unstable" "--fmt" "--justfile" inplace)) "APPEND:non-nil") ``` Minimal `justfile` before formatting (there is one space before `echo`): ```make rule: echo test ``` Expected formatting result (there are four spaces before `echo`): ```make rule: echo test ``` Without this pull request there are no visible changes after <kbd>C-u</kbd> <kbd>M-x</kbd> `apheleia-format-buffer` <kbd>RET</kbd> `just` <kbd>RET</kbd>. When this pull request is applied, formatting proceed as expected. Co-authored-by: Radon Rosborough <radon@intuitiveexplanations.com>
Diffstat (limited to 'apheleia.el')
-rw-r--r--apheleia.el14
1 files changed, 7 insertions, 7 deletions
diff --git a/apheleia.el b/apheleia.el
index 16ae04b..39e4e76 100644
--- a/apheleia.el
+++ b/apheleia.el
@@ -803,11 +803,11 @@ machine from the machine file is available on"))
(let ((input-fname (apheleia--strip-remote input-fname)))
(setq command (mapcar (lambda (arg)
(if (memq arg '(input inplace))
- input-fname
+ (progn
+ (setq output-fname input-fname)
+ input-fname)
arg))
- command)))
- (when (memq 'inplace command)
- (setq output-fname input-fname)))
+ command))))
(when (memq 'output command)
(setq output-fname (apheleia--make-temp-file run-on-remote "apheleia"))
(let ((output-fname (apheleia--strip-remote output-fname)))
@@ -871,9 +871,9 @@ purposes."
(lambda (stdout)
(when output-fname
;; Load output-fname contents into the stdout buffer.
- (erase-buffer)
- (insert-file-contents-literally output-fname))
-
+ (with-current-buffer stdout
+ (erase-buffer)
+ (insert-file-contents-literally output-fname)))
(funcall callback stdout))
:ensure
(lambda ()