;;; cc-mode.el --- major mode for editing C and similar languages
-;; Copyright (C) 1985, 1987, 1992-2015 Free Software Foundation, Inc.
+;; Copyright (C) 1985, 1987, 1992-2016 Free Software Foundation, Inc.
;; Authors: 2003- Alan Mackenzie
;; 1998- Martin Stjernholm
(cc-bytecomp-defvar adaptive-fill-first-line-regexp) ; Emacs
(cc-bytecomp-defun run-mode-hooks) ; Emacs 21.1
-;; We set these variables during mode init, yet we don't require
+;; We set this variable during mode init, yet we don't require
;; font-lock.
(cc-bytecomp-defvar font-lock-defaults)
-(cc-bytecomp-defvar font-lock-syntactic-keywords)
;; Menu support for both XEmacs and Emacs. If you don't have easymenu
;; with your version of Emacs, you are incompatible!
and the line breaking/filling code. Intended to be used by other
packages that embed CC Mode.
-MODE is the CC Mode flavor to set up, e.g. 'c-mode or 'java-mode.
+MODE is the CC Mode flavor to set up, e.g. `c-mode' or `java-mode'.
DEFAULT-STYLE tells which indentation style to install. It has the
same format as `c-default-style'.
(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)
customary in CC Mode modes but which aren't strictly necessary for CC
Mode to operate correctly.
-MODE is the symbol for the mode to initialize, like 'c-mode. See
+MODE is the symbol for the mode to initialize, like `c-mode'. See
`c-basic-common-init' for details. It's only optional to be
compatible with old code; callers should always specify it."
(funcall fn (point-min) (point-max)))
c-get-state-before-change-functions)
(mapc (lambda (fn)
- (funcall fn (point-min) (point-max)
- (- (point-max) (point-min))))
+ (if (not (eq fn 'c-restore-<>-properties))
+ (funcall fn (point-min) (point-max)
+ (- (point-max) (point-min)))))
c-before-font-lock-functions))))
(set (make-local-variable 'outline-regexp) "[^#\n\^M]")
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)