;; derived-mode-ex.el>.
(defun c-leave-cc-mode-mode ()
- (setq c-buffer-is-cc-mode nil))
+ (when c-buffer-is-cc-mode
+ (save-restriction
+ (widen)
+ (c-save-buffer-state ()
+ (c-clear-char-properties (point-min) (point-max) 'category)
+ (c-clear-char-properties (point-min) (point-max) 'syntax-table)
+ (c-clear-char-properties (point-min) (point-max) 'c-is-sws)
+ (c-clear-char-properties (point-min) (point-max) 'c-in-sws)
+ (c-clear-char-properties (point-min) (point-max) 'c-type)
+ (if (c-major-mode-is 'awk-mode)
+ (c-clear-char-properties (point-min) (point-max) 'c-awk-NL-prop))))
+ (setq c-buffer-is-cc-mode nil)))
(defun c-init-language-vars-for (mode)
"Initialize the language variables for one of the language modes
(not (string-equal c-indentation-style
style)))))))
(c-setup-paragraph-variables)
+ (c-make-noise-macro-regexps)
;; we have to do something special for c-offsets-alist so that the
;; buffer local value has its own alist structure.
(font-lock-mode 1)))
;; Buffer local variables defining the region to be fontified by a font lock
-;; after-change function. They are set in c-after-change to
-;; after-change-functions' BEG and END, and may be modified by functions in
+;; after-change function. They are initialized in c-before-change to
+;; before-change-functions' BEG and END. `c-new-END' is amended in
+;; c-after-change with after-change-functions' BEG, END, and OLD-LEN. These
+;; variables may be modified by any before/after-change function, in
+;; particular by functions in `c-get-state-before-change-functions' and
;; `c-before-font-lock-functions'.
(defvar c-new-BEG 0)
(make-variable-buffer-local 'c-new-BEG)
c-just-done-before-change) ; guard against a spurious second
; invocation of before-change-functions.
(setq c-just-done-before-change t)
+ ;; (c-new-BEG c-new-END) will be the region to fontify.
+ (setq c-new-BEG beg c-new-END end)
(setq c-maybe-stale-found-type nil)
(save-restriction
(save-match-data
;; (c-new-BEG c-new-END) will be the region to fontify. It may become
;; larger than (beg end).
- (setq c-new-BEG beg c-new-END end)
+ ;; (setq c-new-BEG beg c-new-END end)
+ (setq c-new-END (- (+ c-new-END (- end beg)) old-len))
(unless (c-called-from-text-property-change-p)
(setq c-just-done-before-change nil)
(save-restriction
(widen)
(save-excursion
- (let ((new-beg beg) (new-end end) new-region)
+ (let ((new-beg beg) (new-end end)
+ (new-region (cons beg end)))
(mapc (lambda (fn)
(setq new-region (funcall fn new-beg new-end))
(setq new-beg (car new-region) new-end (cdr new-region)))
. c-mark-function)))
;; Prevent `font-lock-default-fontify-region' extending the region it will
- ;; fontify to whole lines by removing `font-lock-extend-region-whole-lines'
- ;; (and, coincidentally, `font-lock-extend-region-multiline' (which we do
- ;; not need)) from `font-lock-extend-region-functions'. (Emacs only). This
- ;; fixes Emacs bug #19669.
+ ;; fontify to whole lines by removing `font-lock-extend-region-wholelines'
+ ;; from `font-lock-extend-region-functions'. (Emacs only). This fixes
+ ;; Emacs bug #19669.
(when (boundp 'font-lock-extend-region-functions)
- (setq font-lock-extend-region-functions nil))
+ (setq font-lock-extend-region-functions
+ (delq 'font-lock-extend-region-wholelines
+ font-lock-extend-region-functions)))
(make-local-variable 'font-lock-fontify-region-function)
(setq font-lock-fontify-region-function 'c-font-lock-fontify-region)