diff --git a/modules/lang/haskell/+dante.el b/modules/lang/haskell/+dante.el index 7ae27e319..8b1f3cb82 100644 --- a/modules/lang/haskell/+dante.el +++ b/modules/lang/haskell/+dante.el @@ -19,6 +19,16 @@ (set-company-backend! 'dante-mode #'dante-company) + (defun +haskell*restore-modified-state (orig-fn &rest args) + "Dante quietly saves the current buffer (without triggering save hooks) before +invoking flycheck, unexpectedly leaving the buffer in an unmodified state. This +is annoying if we depend on save hooks to do work on the buffer (like +reformatting), so we restore a (false) modified state." + (let ((modified-p (buffer-modified-p))) + (apply orig-fn args) + (if modified-p (set-buffer-modified-p t)))) + (advice-add #'dante-async-load-current-buffer :around #'+haskell*restore-modified-state) + (when (featurep 'evil) (add-hook 'dante-mode-hook #'evil-normalize-keymaps)) (map! :map dante-mode-map