Fix doom-guess-mode-h being too aggressive
It would trigger set-auto-mode whenever files are written to (e.g. when persp-mode writes its workspace/session files, which have unsafe local variables, so the user is inundated with prompts to accept them). Now, doom-guess-mode-h will only work on files with shebang lines.
This commit is contained in:
parent
22ae9cca15
commit
9b003e0516
1 changed files with 7 additions and 3 deletions
|
@ -80,9 +80,13 @@ possible."
|
||||||
(add-hook! 'after-save-hook
|
(add-hook! 'after-save-hook
|
||||||
(defun doom-guess-mode-h ()
|
(defun doom-guess-mode-h ()
|
||||||
"Guess mode when saving a file in `fundamental-mode'."
|
"Guess mode when saving a file in `fundamental-mode'."
|
||||||
(when (and (eq major-mode 'fundamental-mode)
|
(and (eq major-mode 'fundamental-mode)
|
||||||
(buffer-file-name (buffer-base-buffer)))
|
(buffer-file-name (buffer-base-buffer))
|
||||||
(set-auto-mode))))
|
(>= (buffer-size) 2)
|
||||||
|
(save-restriction
|
||||||
|
(widen)
|
||||||
|
(string= "#!" (buffer-substring (point-min) (+ 2 (point-min)))))
|
||||||
|
(set-auto-mode))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue