This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-01-23
Channels
- # aleph (1)
- # architecture (4)
- # aws (7)
- # beginners (249)
- # boot (17)
- # calva (4)
- # cider (30)
- # cljdoc (7)
- # cljs-dev (1)
- # cljs-experience (3)
- # clojure (69)
- # clojure-dev (7)
- # clojure-europe (1)
- # clojure-italy (7)
- # clojure-japan (15)
- # clojure-spec (6)
- # clojure-uk (39)
- # clojurescript (51)
- # cursive (31)
- # data-science (4)
- # datavis (1)
- # datomic (40)
- # dirac (67)
- # duct (8)
- # editors (15)
- # emacs (9)
- # events (3)
- # figwheel-main (2)
- # fulcro (157)
- # juxt (4)
- # kaocha (11)
- # lein-figwheel (1)
- # off-topic (31)
- # pathom (18)
- # re-frame (4)
- # reagent (2)
- # reitit (16)
- # remote-jobs (1)
- # shadow-cljs (11)
- # specter (2)
- # speculative (1)
- # tools-deps (27)
- # vim (1)
- # yada (2)
I made a function as such
(defun user-prettier-eslint ()
"Format the current file with ESLint."
(interactive)
(let* ((binary (executable-find "prettier-eslint_d"))
(command (format "cat %s | %s --stdin | tee %s" buffer-file-name binary buffer-file-name)))
(progn
;;(save-buffer)
(shell-command command "*test-buffer*" "*prettier-eslint-errors*")
(revert-buffer t t t))))
;; ===prettier-eslint
(add-hook 'js2-mode-hook (lambda () (add-hook 'after-save-hook 'user-prettier-eslint nil t)))
(add-hook 'web-mode-hook (lambda () (add-hook 'after-save-hook 'user-prettier-eslint nil t)))
and noticed that sometimes after saving a blank file is fed into the command. I uncommented the (save-buffer)
to resolve it, but it seems redundant. I'm not sure if the blank content is some thing I have to wait for emacs to finish saving but wondering what the issue is.could it be that your defun is being invoked N times per save? I think those hooks might pile up as you open more and more files
also, the commented-out save-buffer
would end up triggering your hook again, right? seems recursive
I thought so, but it doens't seem to since the doc says
Add to the value of HOOK the function FUNCTION.
FUNCTION is not added if already present.
FUNCTION is added (if necessary) at the beginning of the hook list
unless the optional argument APPEND is non-nil, in which case
FUNCTION is added at the end.
going to restart to see if I can reproduce
seems this is happening randomly with the command itself, some calls to cat somefile.js | prettier-eslint_d --stdin
gives a blank result
seems to work when I use prettier-js and set the command to prettier-eslint_d.
I filed an issue in the meantime, not sure if it's some weird piping issue or the command with that argument