1

I've seen the post Magit: Auto-refresh “magit-status”, and tarsius recommends the same method from the Magit manual to set magit-after-save-refresh-status to non-nil to the after-save-hook:

(add-hook 'after-save-hook 'magit-after-save-refresh-status t)

This is a great solution when a Magit buffer is available. However, if this setting causes some noisy warnings when saving a file when a Magit buffer is not available:

run-hooks: Symbol’s function definition is void: magit-after-save-refresh-status

How can I get around this such that this setting is active only when there is a Magit buffer available?

3

The problem isn't that no Magit buffer exists but rather that Magit has not even been loaded. The result is that Symbol’s function definition is void: magit-after-save-refresh-status.

So you have to delay adding this function to the hook until it actually exists, like so:

(with-eval-after-load 'magit-mode
  (add-hook 'after-save-hook 'magit-after-save-refresh-status t))
| improve this answer | |
  • Thank you! @tarsius, I see you're a maintainer of magit – could the config snippet here be amended to this? – jidiculous Mar 23 at 22:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.