Don't modify buffer on whitespace injection (#110)
In doom|inject-trailing-whitespace, for highlight-indentation-mode
This commit is contained in:
parent
2dc6ea0f53
commit
3f69ebdfc8
1 changed files with 7 additions and 8 deletions
|
@ -200,12 +200,11 @@ file."
|
||||||
(list (region-beginning) (region-end))
|
(list (region-beginning) (region-end))
|
||||||
(list nil nil))))
|
(list nil nil))))
|
||||||
(unless indent-tabs-mode
|
(unless indent-tabs-mode
|
||||||
(save-match-data
|
(with-silent-modifications
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(let ((end-marker (copy-marker (or end (point-max))))
|
(goto-char (or start (point-min)))
|
||||||
(start (or start (point-min))))
|
(save-match-data
|
||||||
(goto-char start)
|
(while (and (re-search-forward "^$" nil t) (< (point) (point-max)))
|
||||||
(while (and (re-search-forward "^$" end-marker t) (< (point) end-marker))
|
|
||||||
(let (line-start line-end next-start next-end)
|
(let (line-start line-end next-start next-end)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
;; Check previous line indent
|
;; Check previous line indent
|
||||||
|
@ -223,8 +222,7 @@ file."
|
||||||
(next-indent (- next-end next-start))
|
(next-indent (- next-end next-start))
|
||||||
(indent (min line-indent next-indent)))
|
(indent (min line-indent next-indent)))
|
||||||
(insert (make-string (if (zerop indent) 0 (1+ indent)) ? )))))
|
(insert (make-string (if (zerop indent) 0 (1+ indent)) ? )))))
|
||||||
(forward-line 1)))))
|
(forward-line 1))))))
|
||||||
(set-buffer-modified-p nil))
|
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
(defun doom|init-highlight-indentation ()
|
(defun doom|init-highlight-indentation ()
|
||||||
|
@ -235,7 +233,8 @@ file."
|
||||||
(add-hook 'after-save-hook #'doom|inject-trailing-whitespace nil t))
|
(add-hook 'after-save-hook #'doom|inject-trailing-whitespace nil t))
|
||||||
(remove-hook 'before-save-hook #'delete-trailing-whitespace t)
|
(remove-hook 'before-save-hook #'delete-trailing-whitespace t)
|
||||||
(remove-hook 'after-save-hook #'doom|inject-trailing-whitespace t)
|
(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