lang/haskell: restore modified flag after flycheck

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.
This commit is contained in:
Henrik Lissner 2019-02-21 19:11:07 -05:00
parent afae6e4f1d
commit 499877fcff
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -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