mirror of
https://github.com/doomemacs/doomemacs
synced 2025-08-03 12:27:26 -05:00
Make whitespace-injection more robust
+ No longer try to affect read-only buffers + Only activate if indent-tabs-mode is nil (spaces)
This commit is contained in:
@ -198,10 +198,10 @@ mode is detected.")
|
||||
buffer so that `highlight-indentation-mode' will display uninterrupted indent
|
||||
markers. This whitespace is stripped out on save, as not to affect the resulting
|
||||
file."
|
||||
(interactive (progn (barf-if-buffer-read-only)
|
||||
(if (use-region-p)
|
||||
(interactive (if (use-region-p)
|
||||
(list (region-beginning) (region-end))
|
||||
(list nil nil))))
|
||||
(list nil nil)))
|
||||
(barf-if-buffer-read-only)
|
||||
(unless indent-tabs-mode
|
||||
(with-silent-modifications
|
||||
(save-excursion
|
||||
@ -229,6 +229,7 @@ file."
|
||||
nil)
|
||||
|
||||
(defun doom|init-highlight-indentation ()
|
||||
(unless (or indent-tabs-mode buffer-read-only)
|
||||
(if (or highlight-indentation-mode highlight-indentation-current-column-mode)
|
||||
(progn
|
||||
(doom|inject-trailing-whitespace)
|
||||
@ -237,7 +238,7 @@ file."
|
||||
(remove-hook 'before-save-hook #'delete-trailing-whitespace t)
|
||||
(remove-hook 'after-save-hook #'doom|inject-trailing-whitespace t)
|
||||
(with-silent-modifications
|
||||
(delete-trailing-whitespace))))
|
||||
(delete-trailing-whitespace)))))
|
||||
(add-hook! (highlight-indentation-mode highlight-indentation-current-column-mode)
|
||||
#'doom|init-highlight-indentation))
|
||||
|
||||
|
Reference in New Issue
Block a user