Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apheleia with zprint question #1

Open
mihai-dinu opened this issue Feb 12, 2021 · 0 comments
Open

Apheleia with zprint question #1

mihai-dinu opened this issue Feb 12, 2021 · 0 comments

Comments

@mihai-dinu
Copy link

mihai-dinu commented Feb 12, 2021

Hi Anders, I didn't know how else to contact you other than this so here I am creating an issue for a question. I found your blog where you were using zprint for clojure formatting. I have tried using it as well, but without success. My problem is that it looks like Apheleia is calling it's formatters with make-process and that does not work well with shell redirection as far as I could tell.

Here is my apheleia use-package

(use-package! apheleia
  :defer t
  :hook ((typescript-mode . apheleia-mode)
         (javascript-mode . apheleia-mode)
         (js2-mode . apheleia-mode)
         (clojure-mode . apheleia-mode))
  :config
  (setf (alist-get 'clj-zprint apheleia-formatters)
        '("clj-zprint"
          "{:style [:community :justified] :map {:comma? false}} <"
          file))
  (add-to-list 'apheleia-mode-alist '(clojure-mode . clj-zprint)))

And here is what I've tried to reproduce the issue:

(defun testcmd ()
  (let* ((command '("clj-zprint"
                    "{:style [:community :justified] :map {:comma? false}} <"
                    "/Users/dimiha/code/personal/clojure/fwpd/src/fwpd/core.clj"
                    ))
        (proc (make-process
               :name "zprint"
               :buffer (current-buffer)
               :command command)))))

(testcmd)
Unknown switch '/Users/dimiha/code/personal/clojure/fwpd/src/fwpd/core.clj'

Process zprint exited abnormally with code 1

As you can see, the process exits with status code 1 and what I think happens is that Emacs doesn't know how to do stdin redirection (<) when running a process outside a shell.

Have you had this problem as well? Or do you have any ideas why this is happening?

Thanks in advance!

Relevant code from your repo:

.emacs.d/init.el

Lines 732 to 735 in 15a040e

(setf (alist-get 'clj-zprint apheleia-formatters)
'("clj-zprint"
"{:style [:community :justified] :map {:comma? false}} <"
file))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant