Function: syntax-ppss-flush-cache
syntax-ppss-flush-cache is a byte-compiled function defined in
syntax.el.gz.
Signature
(syntax-ppss-flush-cache BEG &rest IGNORED)
Documentation
Flush the cache of syntax-ppss starting at position BEG.
Aliases
syntax-ppss-after-change-function (obsolete since 27.1)
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/syntax.el.gz
(defun syntax-ppss-flush-cache (beg &rest _ignored)
"Flush the cache of `syntax-ppss' starting at position BEG."
;; Set syntax-propertize to refontify anything past beg.
(unless (syntax-propertize--in-process-p)
(setq syntax-propertize--done (min beg syntax-propertize--done)))
;; Flush invalid cache entries.
(dolist (cell (list syntax-ppss-wide syntax-ppss-narrow))
(pcase cell
(`(,last . ,cache)
(while (and cache (> (caar cache) beg))
(setq cache (cdr cache)))
;; Throw away `last' value if made invalid.
(when (< beg (or (car last) 0))
;; If syntax-begin-function jumped to BEG, then the old state at BEG can
;; depend on the text after BEG (which is presumably changed). So if
;; BEG=(car (nth 10 syntax-ppss-last)) don't reuse that data because the
;; assumed nil state at BEG may not be valid any more.
(if (<= beg (or (syntax-ppss-toplevel-pos (cdr last))
(nth 3 last)
0))
(setq last nil)
(setcar last nil)))
;; Unregister if there's no cache left. Sadly this doesn't work
;; because `before-change-functions' is temporarily bound to nil here.
;; (unless cache
;; (remove-hook 'before-change-functions #'syntax-ppss-flush-cache t))
(setcar cell last)
(setcdr cell cache)))
))