From 3f69ebdfc8b67531eaf4b125ecec5a55182d9207 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 16 Jun 2017 02:02:35 +0200 Subject: [PATCH] Don't modify buffer on whitespace injection (#110) In doom|inject-trailing-whitespace, for highlight-indentation-mode --- core/core-ui.el | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/core/core-ui.el b/core/core-ui.el index 422960771..40d972ff9 100644 --- a/core/core-ui.el +++ b/core/core-ui.el @@ -200,12 +200,11 @@ file." (list (region-beginning) (region-end)) (list nil nil)))) (unless indent-tabs-mode - (save-match-data + (with-silent-modifications (save-excursion - (let ((end-marker (copy-marker (or end (point-max)))) - (start (or start (point-min)))) - (goto-char start) - (while (and (re-search-forward "^$" end-marker t) (< (point) end-marker)) + (goto-char (or start (point-min))) + (save-match-data + (while (and (re-search-forward "^$" nil t) (< (point) (point-max))) (let (line-start line-end next-start next-end) (save-excursion ;; Check previous line indent @@ -223,8 +222,7 @@ file." (next-indent (- next-end next-start)) (indent (min line-indent next-indent))) (insert (make-string (if (zerop indent) 0 (1+ indent)) ? ))))) - (forward-line 1))))) - (set-buffer-modified-p nil)) + (forward-line 1)))))) nil) (defun doom|init-highlight-indentation () @@ -235,7 +233,8 @@ file." (add-hook 'after-save-hook #'doom|inject-trailing-whitespace nil t)) (remove-hook 'before-save-hook #'delete-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) #'doom|init-highlight-indentation))