Fix dtrt-indent errors in broken smie modes
Some smie modes throw errors when trying to guess their indentation, like `nim-mode'. This prevents them from leaving Emacs in a broken state.
This commit is contained in:
parent
bfe7b9f1c4
commit
c1fa37245f
1 changed files with 16 additions and 1 deletions
|
@ -216,7 +216,22 @@ savehist file."
|
|||
#'doom|detect-indentation)
|
||||
:config
|
||||
(setq dtrt-indent-verbosity (if doom-debug-mode 2 0))
|
||||
(add-to-list 'dtrt-indent-hook-generic-mapping-list '(t tab-width)))
|
||||
(add-to-list 'dtrt-indent-hook-generic-mapping-list '(t tab-width))
|
||||
|
||||
(defun doom*fix-broken-smie-modes (orig-fn arg)
|
||||
"Some smie modes throw errors when trying to guess their indentation, like
|
||||
`nim-mode'. This prevents them from leaving Emacs in a broken state."
|
||||
(let ((dtrt-indent-run-after-smie dtrt-indent-run-after-smie))
|
||||
(cl-letf* ((old-smie-config-guess (symbol-function 'smie-config-guess))
|
||||
((symbol-function 'smie-config-guess)
|
||||
(lambda ()
|
||||
(condition-case e (funcall old-smie-config-guess)
|
||||
(error (setq dtrt-indent-run-after-smie t)
|
||||
(message "[WARNING] Indent detection: %s"
|
||||
(error-message-string e))
|
||||
(message "")))))) ; warn silently
|
||||
(funcall orig-fn arg))))
|
||||
(advice-add #'dtrt-indent-mode :around #'doom*fix-broken-smie-modes))
|
||||
|
||||
;; Branching undo
|
||||
(def-package! undo-tree
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue