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."
(when (or (not (eq whitespace-point (point)))
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 (point-min) whitespace-bob-marker))
(when (>= (max (point) whitespace-point) whitespace-eob-marker)
(font-lock-flush whitespace-eob-marker (point-max))))
(setq-local whitespace-buffer-changed nil)
(setq whitespace-point (point)) ; current point position
(let ((refontify (or (and (eolp) ; It is at end of line ...
;; ... with trailing SPACE or TAB
(or (memq (preceding-char) '(?\s ?\t)))
(line-beginning-position))
(and (memq 'missing-newline-at-eof
;; If user requested to highlight
;; EOB without a newline...
whitespace-active-style)
;; ...and the buffer is not empty...
(not (= (point-min) (point-max)))
(= (point-max) (without-restriction (point-max)))
;; ...and no newline at EOB...
(not (eq (char-before (point-max)) ?\n))
;; ...then refontify the last character in
;; the buffer
(max (1- (point-max)) (point-min)))))
(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))))))