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))
(when (and (not whitespace-buffer-changed)
(memq 'empty whitespace-active-style))
;; No need to handle the `whitespace-buffer-changed' case here
;; because that is taken care of by the `font-lock-multiline'
;; text property.
(when (<= (min (point) whitespace-point) whitespace-bob-marker)
(font-lock-flush 1 whitespace-bob-marker))
(when (>= (max (point) whitespace-point) whitespace-eob-marker)
(font-lock-flush whitespace-eob-marker (1+ (buffer-size)))))
(setq-local whitespace-buffer-changed nil)
(setq whitespace-point (point)) ; current point position
(let ((refontify (and (eolp) ; It is at end of line ...
;; ... with trailing SPACE or TAB
(or (memq (preceding-char) '(?\s ?\t)))
(line-beginning-position)))
(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))))))