mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-01 12:17:25 -05:00
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:
@ -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
|
||||
|
Reference in New Issue
Block a user