[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs/lisp/progmodes cc-langs.el cc-mode.el
From: |
Alan Mackenzie |
Subject: |
[Emacs-diffs] emacs/lisp/progmodes cc-langs.el cc-mode.el |
Date: |
Tue, 19 May 2009 22:35:08 +0000 |
CVSROOT: /cvsroot/emacs
Module name: emacs
Changes by: Alan Mackenzie <acmacm> 09/05/19 22:35:08
Modified files:
lisp/progmodes : cc-langs.el cc-mode.el
Log message:
cc-mode.el (c-extend-and-neutralize-CPP-line): Renamed from
c-neutralize-syntax-in-CPP. Set the variables c-new-BEG and c-new-END,
thus extending the font-lock region.
(c-font-lock-init): Don't set obsolete variable font-lock-lines-before.
cc-langs.el (c-before-font-lock-function): Rename a value to
c-extend-and-neutralize-syntax-in-CPP.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/progmodes/cc-langs.el?cvsroot=emacs&r1=1.66&r2=1.67
http://cvs.savannah.gnu.org/viewcvs/emacs/lisp/progmodes/cc-mode.el?cvsroot=emacs&r1=1.83&r2=1.84
Patches:
Index: cc-langs.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-langs.el,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -b -r1.66 -r1.67
--- cc-langs.el 30 Apr 2009 10:36:24 -0000 1.66
+++ cc-langs.el 19 May 2009 22:35:07 -0000 1.67
@@ -461,7 +461,7 @@
When the mode is initialized, this function is called with
parameters \(point-min), \(point-max) and <buffer size>."
t nil
- (c c++ objc) 'c-neutralize-syntax-in-CPP
+ (c c++ objc) 'c-extend-and-neutralize-syntax-in-CPP
awk 'c-awk-extend-and-syntax-tablify-region)
(c-lang-defvar c-before-font-lock-function
(c-lang-const c-before-font-lock-function))
Index: cc-mode.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/progmodes/cc-mode.el,v
retrieving revision 1.83
retrieving revision 1.84
diff -u -b -r1.83 -r1.84
--- cc-mode.el 30 Jan 2009 21:24:22 -0000 1.83
+++ cc-mode.el 19 May 2009 22:35:07 -0000 1.84
@@ -606,7 +606,8 @@
(make-local-hook 'after-change-functions)
(add-hook 'after-change-functions 'c-after-change nil t)
(set (make-local-variable 'font-lock-extend-after-change-region-function)
- 'c-extend-after-change-region)) ; Currently (2008-04), only used by AWK.
+ 'c-extend-after-change-region)) ; Currently (2009-05) used by all
+ ; lanaguages with #define (C, C++,; ObjC), and by AWK.
(defun c-setup-doc-comment-style ()
"Initialize the variables that depend on the value of `c-doc-comment-style'."
@@ -846,11 +847,15 @@
t)
(t nil)))))))
-(defun c-neutralize-syntax-in-CPP (begg endd old-len)
- ;; "Neutralize" every preprocessor line wholly or partially in the changed
- ;; region. "Restore" lines which were CPP lines before the change and are
- ;; no longer so; these can be located from the Buffer local variables
- ;; c-old-[EB]OM.
+(defun c-extend-and-neutralize-syntax-in-CPP (begg endd old-len)
+ ;; (i) Extend the font lock region to cover all changed preprocessor
+ ;; regions; it does this by setting the variables `c-new-BEG' and
+ ;; `c-new-END' to the new boundaries.
+ ;;
+ ;; (ii) "Neutralize" every preprocessor line wholly or partially in the
+ ;; extended changed region. "Restore" lines which were CPP lines before the
+ ;; change and are no longer so; these can be located from the Buffer local
+ ;; variables `c-old-BOM' and `c-old-EOM'.
;;
;; That is, set syntax-table properties on characters that would otherwise
;; interact syntactically with those outside the CPP line(s).
@@ -867,11 +872,12 @@
;; Note: SPEED _MATTERS_ IN THIS FUNCTION!!!
;;
;; This function might make hidden buffer changes.
- (c-save-buffer-state (limits mbeg+1 beg end)
- ;; First determine the region, (beg end), which may need "neutralizing".
- ;; This may not start inside a string, comment, or macro.
+ (c-save-buffer-state (limits mbeg+1)
+ ;; First determine the region, (c-new-BEG c-new-END), which will get font
+ ;; locked. It might need "neutralizing". This region may not start
+ ;; inside a string, comment, or macro.
(goto-char c-old-BOM) ; already set to old start of macro or begg.
- (setq beg
+ (setq c-new-BEG
(if (setq limits (c-literal-limits))
(cdr limits) ; go forward out of any string or comment.
(point)))
@@ -881,16 +887,17 @@
(goto-char (car limits))) ; go backward out of any string or comment.
(if (c-beginning-of-macro)
(c-end-of-macro))
- (setq end (max (+ (- c-old-EOM old-len) (- endd begg))
+ (setq c-new-END (max (+ (- c-old-EOM old-len) (- endd begg))
(point)))
- ;; Clear all old punctuation properties
- (c-clear-char-property-with-value beg end 'syntax-table '(1))
+ ;; Clear any existing punctuation properties.
+ (c-clear-char-property-with-value c-new-BEG c-new-END 'syntax-table '(1))
- (goto-char beg)
- (let ((pps-position beg) pps-state)
- (while (and (< (point) end)
- (search-forward-regexp c-anchored-cpp-prefix end t))
+ ;; Add needed properties to each CPP construct in the region.
+ (goto-char c-new-BEG)
+ (let ((pps-position c-new-BEG) pps-state)
+ (while (and (< (point) c-new-END)
+ (search-forward-regexp c-anchored-cpp-prefix c-new-END t))
;; If we've found a "#" inside a string/comment, ignore it.
(setq pps-state
(parse-partial-sexp pps-position (point) nil nil pps-state)
@@ -978,6 +985,8 @@
(buffer-substring-no-properties type-pos term-pos)
(buffer-substring-no-properties beg end)))))))
+ ;; (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)
(if c-get-state-before-change-function
@@ -1048,7 +1057,6 @@
nil nil
,c-identifier-syntax-modifications
c-beginning-of-syntax
- (font-lock-lines-before . 1)
(font-lock-mark-block-function
. c-mark-function)))
@@ -1063,8 +1071,9 @@
;; font-lock-extend-after-change-region-function, is forced to use advice
;; instead.
;;
- ;; Of the seven CC Mode languages, currently (2008-04) only AWK Mode makes
- ;; non-null use of this function.
+ ;; Of the seven CC Mode languages, currently (2009-05) only C, C++, Objc
+ ;; (the languages with #define) and AWK Mode make non-null use of this
+ ;; function.
(cons c-new-BEG c-new-END))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs/lisp/progmodes cc-langs.el cc-mode.el,
Alan Mackenzie <=