[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need assistance in figuring out what reformats my code on save

From: Steinar Bang
Subject: Re: Need assistance in figuring out what reformats my code on save
Date: Mon, 06 Sep 2021 16:26:25 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (windows-nt)

>>>>> Tassilo Horn <>:

> I'd try evaluating

>   (add-hook 'before-change-functions #'debug nil t)

> in a buffer where that formatting before save happens and then save.
> That should put you in the debugger and the backtrace will hopefully
> show you who and from where the formatting is triggered.

Thanks! That worked!

I did
 `M-: (add-hook 'before-change-functions #'debug nil t) RET`
in a .tsx buffer in a restarted emacs with nil before-save-hook and I
found that the reformatting is done by web-mode-on-post-command and is
run immediately after my change, and not just before save.

web-mode-on-post-command is run from the post-command-hook, and runs
indent-region on the buffer when the command is a yank

The formatting done by tide-format-before-save is different from the
formatting done by indent-region in web-mode-on-post-command, and with
tide-format-before-save in place, it's the tide-format-before-save
formatting that wins.

(In case someone finds this when googling: making tsfmt, or making
web-mode, format exactly like prettier, both seemed like too much work.
So I removed tide formatting from web-mode and used "prettier-js for
emacs" instead. See
for details)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]