summaryrefslogtreecommitdiff
path: root/lisp/whitespace.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/whitespace.el')
-rw-r--r--lisp/whitespace.el43
1 files changed, 31 insertions, 12 deletions
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index 25ea07e9db7..558be1841ab 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -2093,6 +2093,17 @@ resultant list will be returned."
t))
+(defun whitespace--clone ()
+ "Hook function run after `make-indirect-buffer' and `clone-buffer'."
+ (when (whitespace-style-face-p)
+ (setq-local whitespace-bob-marker
+ (copy-marker (marker-position whitespace-bob-marker)
+ (marker-insertion-type whitespace-bob-marker)))
+ (setq-local whitespace-eob-marker
+ (copy-marker (marker-position whitespace-eob-marker)
+ (marker-insertion-type whitespace-eob-marker)))))
+
+
(defun whitespace-color-on ()
"Turn on color visualization."
(when (whitespace-style-face-p)
@@ -2111,6 +2122,8 @@ resultant list will be returned."
;; The -1 ensures that it runs before any
;; `font-lock-mode' hook functions.
-1 t)
+ (add-hook 'clone-buffer-hook #'whitespace--clone nil t)
+ (add-hook 'clone-indirect-buffer-hook #'whitespace--clone nil t)
;; Add whitespace-mode color into font lock.
(setq
whitespace-font-lock-keywords
@@ -2204,6 +2217,8 @@ resultant list will be returned."
(remove-hook 'before-change-functions #'whitespace-buffer-changed t)
(remove-hook 'after-change-functions #'whitespace--update-bob-eob
t)
+ (remove-hook 'clone-buffer-hook #'whitespace--clone t)
+ (remove-hook 'clone-indirect-buffer-hook #'whitespace--clone t)
(font-lock-remove-keywords nil whitespace-font-lock-keywords)
(font-lock-flush)))
@@ -2268,10 +2283,11 @@ Highlighting those lines can be distracting.)"
(save-excursion (goto-char whitespace-point)
(line-beginning-position)))))
(when (= p 1)
- ;; See the comment in `whitespace--update-bob-eob' for why this
- ;; text property is added here.
- (put-text-property 1 whitespace-bob-marker
- 'font-lock-multiline t))
+ (with-silent-modifications
+ ;; See the comment in `whitespace--update-bob-eob' for why
+ ;; this text property is added here.
+ (put-text-property 1 whitespace-bob-marker
+ 'font-lock-multiline t)))
(when (< p e)
(set-match-data (list p e))
(goto-char e))))
@@ -2292,10 +2308,11 @@ about to start typing, and if they do, that line and previous
empty lines will no longer be EoB empty lines. Highlighting
those lines can be distracting.)"
(when (= limit (1+ (buffer-size)))
- ;; See the comment in `whitespace--update-bob-eob' for why this
- ;; text property is added here.
- (put-text-property whitespace-eob-marker limit
- 'font-lock-multiline t))
+ (with-silent-modifications
+ ;; See the comment in `whitespace--update-bob-eob' for why this
+ ;; text property is added here.
+ (put-text-property whitespace-eob-marker limit
+ 'font-lock-multiline t)))
(let ((b (max (point) whitespace-eob-marker
whitespace-bob-marker ; See comment in the bob func.
(save-excursion (goto-char whitespace-point)
@@ -2437,8 +2454,9 @@ purposes)."
(save-match-data
(when (looking-at whitespace-empty-at-bob-regexp)
(set-marker whitespace-bob-marker (match-end 1))
- (put-text-property (match-beginning 1) (match-end 1)
- 'font-lock-multiline t))))
+ (with-silent-modifications
+ (put-text-property (match-beginning 1) (match-end 1)
+ 'font-lock-multiline t)))))
(when (or (null end)
(>= end (save-excursion
(goto-char whitespace-eob-marker)
@@ -2451,8 +2469,9 @@ purposes)."
(when (whitespace--looking-back
whitespace-empty-at-eob-regexp)
(set-marker whitespace-eob-marker (match-beginning 1))
- (put-text-property (match-beginning 1) (match-end 1)
- 'font-lock-multiline t)))))))))
+ (with-silent-modifications
+ (put-text-property (match-beginning 1) (match-end 1)
+ 'font-lock-multiline t))))))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;