summaryrefslogtreecommitdiff
path: root/lisp/whitespace.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2005-04-08 14:40:57 +0000
committerStefan Monnier <monnier@iro.umontreal.ca>2005-04-08 14:40:57 +0000
commitc22c3db00e9345869817da8ebf441647c1ae35f3 (patch)
treee3545d646c88678761007bbf435759aaff26c352 /lisp/whitespace.el
parentea81d57ec51f81205135e3ce340345a159f9269f (diff)
downloademacs-c22c3db00e9345869817da8ebf441647c1ae35f3.tar.gz
(whitespace-highlight-the-space): Put the same overlay
in the buffer and in whitespace-highlighted-space. (whitespace-unhighlight-the-space): Simplify. (whitespace-buffer): Simplify.
Diffstat (limited to 'lisp/whitespace.el')
-rw-r--r--lisp/whitespace.el32
1 files changed, 11 insertions, 21 deletions
diff --git a/lisp/whitespace.el b/lisp/whitespace.el
index 81a0aec9100..4406a0615ee 100644
--- a/lisp/whitespace.el
+++ b/lisp/whitespace.el
@@ -489,16 +489,14 @@ and:
(if whitespace-spacetab "s")
(if whitespace-trailing "t")))))
(whitespace-update-modeline whitespace-this-modeline)
- (save-excursion
- (get-buffer-create whitespace-errbuf)
- (kill-buffer whitespace-errbuf)
- (get-buffer-create whitespace-errbuf)
- (set-buffer whitespace-errbuf)
+ (if (get-buffer whitespace-errbuf)
+ (kill-buffer whitespace-errbuf))
+ (with-current-buffer (get-buffer-create whitespace-errbuf)
(if whitespace-errmsg
(progn
(insert whitespace-errmsg)
(if (not (or quiet whitespace-silent))
- (display-buffer whitespace-errbuf t))
+ (display-buffer (current-buffer) t))
(if (not quiet)
(message "Whitespaces: [%s%s] in %s"
whitespace-this-modeline
@@ -511,9 +509,7 @@ and:
(if (and (not quiet) (not (equal whitespace-clean-msg "")))
(message "%s %s" whitespace-filename
whitespace-clean-msg))))))))
- (if whitespace-error
- t
- nil)))
+ whitespace-error))
;;;###autoload
(defun whitespace-region (s e)
@@ -736,23 +732,17 @@ Also with whitespaces whose testing has been turned off."
(defun whitespace-highlight-the-space (b e)
"Highlight the current line, unhighlighting a previously jumped to line."
(if whitespace-display-spaces-in-color
- (progn
+ (let ((ol (whitespace-make-overlay b e)))
(whitespace-unhighlight-the-space)
- (add-to-list 'whitespace-highlighted-space
- (whitespace-make-overlay b e))
- (whitespace-overlay-put (whitespace-make-overlay b e) 'face
- 'whitespace-highlight-face))))
+ (push ol whitespace-highlighted-space)
+ (whitespace-overlay-put ol 'face 'whitespace-highlight-face))))
;; (add-hook 'pre-command-hook 'whitespace-unhighlight-the-space))
(defun whitespace-unhighlight-the-space ()
"Unhighlight the currently highlight line."
(if (and whitespace-display-spaces-in-color whitespace-highlighted-space)
- (let ((whitespace-this-space nil))
- (while whitespace-highlighted-space
- (setq whitespace-this-space (car whitespace-highlighted-space))
- (setq whitespace-highlighted-space
- (cdr whitespace-highlighted-space))
- (whitespace-delete-overlay whitespace-this-space))
+ (progn
+ (mapc 'whitespace-delete-overlay whitespace-highlighted-space)
(setq whitespace-highlighted-space nil))
(remove-hook 'pre-command-hook 'whitespace-unhighlight-the-space)))
@@ -863,5 +853,5 @@ This is meant to be added buffer-locally to `write-file-functions'."
(provide 'whitespace)
-;;; arch-tag: 4ff44e87-b63c-402d-95a6-15e51e58bd0c
+;; arch-tag: 4ff44e87-b63c-402d-95a6-15e51e58bd0c
;;; whitespace.el ends here