Function: whitespace-post-command-hook
whitespace-post-command-hook is a byte-compiled function defined in
whitespace.el.gz.
Signature
(whitespace-post-command-hook)
Documentation
Save current point into whitespace-point variable.
Also refontify when necessary.
Source Code
;; Defined in /usr/src/emacs/lisp/whitespace.el.gz
(defun whitespace-post-command-hook ()
"Save current point into `whitespace-point' variable.
Also refontify when necessary."
(unless (and (eq whitespace-point (point))
(not whitespace-buffer-changed))
(setq whitespace-point (point)) ; current point position
(let ((refontify
(cond
;; It is at end of buffer (eob).
((= whitespace-point (1+ (buffer-size)))
(when (whitespace-looking-back whitespace-empty-at-eob-regexp
nil)
(match-beginning 0)))
;; It is at end of line ...
((and (eolp)
;; ... with trailing SPACE or TAB
(or (memq (preceding-char) '(?\s ?\t))))
(line-beginning-position))
;; It is at beginning of buffer (bob).
((and (= whitespace-point 1)
(looking-at whitespace-empty-at-bob-regexp))
(match-end 0))))
(ostart (overlay-start whitespace-point--used)))
(cond
((not refontify)
;; New point does not affect highlighting: just refresh the
;; highlighting of old point, if needed.
(when ostart
(font-lock-flush ostart
(overlay-end whitespace-point--used))
(delete-overlay whitespace-point--used)))
((not ostart)
;; Old point did not affect highlighting, but new one does: refresh the
;; highlighting of new point.
(font-lock-flush (min refontify (point)) (max refontify (point))))
((save-excursion
(goto-char ostart)
(setq ostart (line-beginning-position))
(and (<= ostart (max refontify (point)))
(progn
(goto-char (overlay-end whitespace-point--used))
(let ((oend (line-beginning-position 2)))
(<= (min refontify (point)) oend)))))
;; The old point highlighting and the new point highlighting
;; cover a contiguous region: do a single refresh.
(font-lock-flush (min refontify (point) ostart)
(max refontify (point)
(overlay-end whitespace-point--used)))
(delete-overlay whitespace-point--used))
(t
(font-lock-flush (min refontify (point))
(max refontify (point)))
(font-lock-flush ostart (overlay-end whitespace-point--used))
(delete-overlay whitespace-point--used))))))