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:
parent
afae6e4f1d
commit
499877fcff
1 changed files with 10 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue