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:
parent
9c9e410898
commit
8f9bd835a5
1 changed files with 14 additions and 13 deletions
|
@ -198,10 +198,10 @@ mode is detected.")
|
||||||
buffer so that `highlight-indentation-mode' will display uninterrupted indent
|
buffer so that `highlight-indentation-mode' will display uninterrupted indent
|
||||||
markers. This whitespace is stripped out on save, as not to affect the resulting
|
markers. This whitespace is stripped out on save, as not to affect the resulting
|
||||||
file."
|
file."
|
||||||
(interactive (progn (barf-if-buffer-read-only)
|
(interactive (if (use-region-p)
|
||||||
(if (use-region-p)
|
(list (region-beginning) (region-end))
|
||||||
(list (region-beginning) (region-end))
|
(list nil nil)))
|
||||||
(list nil nil))))
|
(barf-if-buffer-read-only)
|
||||||
(unless indent-tabs-mode
|
(unless indent-tabs-mode
|
||||||
(with-silent-modifications
|
(with-silent-modifications
|
||||||
(save-excursion
|
(save-excursion
|
||||||
|
@ -229,15 +229,16 @@ file."
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
(defun doom|init-highlight-indentation ()
|
(defun doom|init-highlight-indentation ()
|
||||||
(if (or highlight-indentation-mode highlight-indentation-current-column-mode)
|
(unless (or indent-tabs-mode buffer-read-only)
|
||||||
(progn
|
(if (or highlight-indentation-mode highlight-indentation-current-column-mode)
|
||||||
(doom|inject-trailing-whitespace)
|
(progn
|
||||||
(add-hook 'before-save-hook #'delete-trailing-whitespace nil t)
|
(doom|inject-trailing-whitespace)
|
||||||
(add-hook 'after-save-hook #'doom|inject-trailing-whitespace nil t))
|
(add-hook 'before-save-hook #'delete-trailing-whitespace nil t)
|
||||||
(remove-hook 'before-save-hook #'delete-trailing-whitespace t)
|
(add-hook 'after-save-hook #'doom|inject-trailing-whitespace nil t))
|
||||||
(remove-hook 'after-save-hook #'doom|inject-trailing-whitespace t)
|
(remove-hook 'before-save-hook #'delete-trailing-whitespace t)
|
||||||
(with-silent-modifications
|
(remove-hook 'after-save-hook #'doom|inject-trailing-whitespace t)
|
||||||
(delete-trailing-whitespace))))
|
(with-silent-modifications
|
||||||
|
(delete-trailing-whitespace)))))
|
||||||
(add-hook! (highlight-indentation-mode highlight-indentation-current-column-mode)
|
(add-hook! (highlight-indentation-mode highlight-indentation-current-column-mode)
|
||||||
#'doom|init-highlight-indentation))
|
#'doom|init-highlight-indentation))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue