Function: c-invalidate-sws-region-after
c-invalidate-sws-region-after is a byte-compiled function defined in
cc-engine.el.gz.
Signature
(c-invalidate-sws-region-after BEG END OLD-LEN)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
(defun c-invalidate-sws-region-after (beg end old-len)
;; Called from `after-change-functions'. Remove any stale `c-in-sws' or
;; `c-is-sws' text properties from the vicinity of the change. BEG, END,
;; and OLD-LEN are the standard arguments given to after-change functions.
;;
;; Note that if `c-forward-sws' or `c-backward-sws' are used outside
;; `c-save-buffer-state' or similar then this will remove the cache
;; properties right after they're added.
;;
;; This function does hidden buffer changes.
(when c-sws-lit-limits
(setcar c-sws-lit-limits (min beg (car c-sws-lit-limits)))
(setcdr c-sws-lit-limits
(max end (- (+ (cdr c-sws-lit-limits) (- end beg)) old-len))))
(let ((del-end
(and (> old-len 0)
(c-invalidate-sws-region-after-del beg end old-len)))
(ins-end
(and (> end beg)
(c-invalidate-sws-region-after-ins end))))
(save-excursion
;; Adjust the end to remove the properties in any following simple
;; ws up to and including the next line break, if there is any
;; after the changed region. This is necessary e.g. when a rung
;; marked empty line is converted to a line comment by inserting
;; "//" before the line break. In that case the line break would
;; keep the rung mark which could make a later `c-backward-sws'
;; move into the line comment instead of over it.
(goto-char end)
(skip-chars-forward " \t\f\v")
(when (and (eolp) (not (eobp)))
(setq end (1+ (point)))))
(when (memq c-sws-lit-type '(noise attribute))
(setq beg (car c-sws-lit-limits)
end (cdr c-sws-lit-limits))) ; This last setting may be redundant.
(when (and (= beg end)
(get-text-property beg 'c-in-sws)
(> beg (point-min))
(get-text-property (1- beg) 'c-in-sws))
;; Ensure that an `c-in-sws' range gets broken. Note that it isn't
;; safe to keep a range that was continuous before the change. E.g:
;;
;; #define foo
;; \
;; bar
;;
;; There can be a "ladder" between "#" and "b". Now, if the newline
;; after "foo" is removed then "bar" will become part of the cpp
;; directive instead of a syntactically relevant token. In that
;; case there's no longer syntactic ws from "#" to "b".
(setq beg (1- beg)))
(setq end (max (or del-end end)
(or ins-end end)
(or (cdr c-sws-lit-limits) end)
end))
(c-debug-sws-msg "c-invalidate-sws-region-after [%s..%s]" beg end)
(c-remove-is-and-in-sws beg end)))