0

I'm currently facing an issue where I am trying to save a file, but some save hook is triggering an auto formatting the file in a way that I do not want. I am not sure how to debug this issue. Ideally, I would be able to see all the events being executed when the save-hook is triggered.

Specifically, I want to edit a config file that looks something like this

# # my_config # SOMETHING=foo 

When I save this file, emacs autoformats the document and adds a space before and after =. I do not want this behavior and I am trying to figure out why on earth it's happening.

example gif of this issue: enter image description here

I am opening the buffer in text-mode. These are the minor mode emacs reports are enabled:

Enabled minor modes: Auto-Composition Auto-Compression Auto-Encryption Auto-Insert Blink-Cursor Column-Number Company Dap Dap-Auto-Configure Dap-Tooltip Dap-Ui Dap-Ui-Controls Dap-Ui-Many-Windows Electric-Indent File-Name-Shadow Flx-Ido Flycheck Flyspell Font-Lock Global-Auto-Revert Global-Company Global-Eldoc Global-Flycheck Global-Font-Lock Global-Git-Commit Ido-Everywhere Ido-Vertical Line-Number Lsp-Treemacs-Sync Magit-Auto-Revert Mouse-Wheel Projectile Recentf Save-Place Savehist Shell-Dirtrack Show-Paren Tooltip Transient-Mark Treemacs-Filewatch Treemacs-Follow Treemacs-Fringe-Indicator Treemacs-Git Visual-Line Which-Key Yas Yas-Global 

I am at a loss as to how I can debug this issue. Is there a clever way to see what emacs is doing when the save-hook is triggered?

2
  • Please show your relevant code. Do you see the same problem if you start Emacs with emacs -Q (no init file)? If not, bisect your init file to find the culprit. Commented Sep 28, 2021 at 22:17
  • What save-hook are you referring to? Some variable? (Defined where?) Commented Sep 28, 2021 at 22:18

1 Answer 1

1

The main save hooks are before-save-hook and after-save-hook. You can see the current value of these via e.g. C-h v before-save-hook. You may see something useful in the resulting output that you can search for in your config. You may also find your problem by search through your configuration for the names of the hooks themselves.

Beyond that, you may need to bisect your config to narrow down the source of the problem, as described in this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.