aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2009-05-19 22:35:07 +0000
committerAlan Mackenzie2009-05-19 22:35:07 +0000
commita0526d5ee57f5142e08a281de727cb9ee2cc0ff2 (patch)
tree519fe221942f402b217058a088fab29ddb54b724
parent30d01cdc47ffc7845835f2c7e29e9390a16aca88 (diff)
downloademacs-a0526d5ee57f5142e08a281de727cb9ee2cc0ff2.tar.gz
emacs-a0526d5ee57f5142e08a281de727cb9ee2cc0ff2.zip
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.
-rw-r--r--lisp/progmodes/cc-langs.el2
-rw-r--r--lisp/progmodes/cc-mode.el49
2 files changed, 30 insertions, 21 deletions
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index cc35daa02ff..9c19e791c3e 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -461,7 +461,7 @@ The function is called even when font locking is disabled.
461When the mode is initialized, this function is called with 461When the mode is initialized, this function is called with
462parameters \(point-min), \(point-max) and <buffer size>." 462parameters \(point-min), \(point-max) and <buffer size>."
463 t nil 463 t nil
464 (c c++ objc) 'c-neutralize-syntax-in-CPP 464 (c c++ objc) 'c-extend-and-neutralize-syntax-in-CPP
465 awk 'c-awk-extend-and-syntax-tablify-region) 465 awk 'c-awk-extend-and-syntax-tablify-region)
466(c-lang-defvar c-before-font-lock-function 466(c-lang-defvar c-before-font-lock-function
467 (c-lang-const c-before-font-lock-function)) 467 (c-lang-const c-before-font-lock-function))
diff --git a/lisp/progmodes/cc-mode.el b/lisp/progmodes/cc-mode.el
index fff1c53c799..dbdb2e7cc45 100644
--- a/lisp/progmodes/cc-mode.el
+++ b/lisp/progmodes/cc-mode.el
@@ -606,7 +606,8 @@ that requires a literal mode spec at compile time."
606 (make-local-hook 'after-change-functions) 606 (make-local-hook 'after-change-functions)
607 (add-hook 'after-change-functions 'c-after-change nil t) 607 (add-hook 'after-change-functions 'c-after-change nil t)
608 (set (make-local-variable 'font-lock-extend-after-change-region-function) 608 (set (make-local-variable 'font-lock-extend-after-change-region-function)
609 'c-extend-after-change-region)) ; Currently (2008-04), only used by AWK. 609 'c-extend-after-change-region)) ; Currently (2009-05) used by all
610 ; lanaguages with #define (C, C++,; ObjC), and by AWK.
610 611
611(defun c-setup-doc-comment-style () 612(defun c-setup-doc-comment-style ()
612 "Initialize the variables that depend on the value of `c-doc-comment-style'." 613 "Initialize the variables that depend on the value of `c-doc-comment-style'."
@@ -846,11 +847,15 @@ Note that the style variables are always made local to the buffer."
846 t) 847 t)
847 (t nil))))))) 848 (t nil)))))))
848 849
849(defun c-neutralize-syntax-in-CPP (begg endd old-len) 850(defun c-extend-and-neutralize-syntax-in-CPP (begg endd old-len)
850 ;; "Neutralize" every preprocessor line wholly or partially in the changed 851 ;; (i) Extend the font lock region to cover all changed preprocessor
851 ;; region. "Restore" lines which were CPP lines before the change and are 852 ;; regions; it does this by setting the variables `c-new-BEG' and
852 ;; no longer so; these can be located from the Buffer local variables 853 ;; `c-new-END' to the new boundaries.
853 ;; c-old-[EB]OM. 854 ;;
855 ;; (ii) "Neutralize" every preprocessor line wholly or partially in the
856 ;; extended changed region. "Restore" lines which were CPP lines before the
857 ;; change and are no longer so; these can be located from the Buffer local
858 ;; variables `c-old-BOM' and `c-old-EOM'.
854 ;; 859 ;;
855 ;; That is, set syntax-table properties on characters that would otherwise 860 ;; That is, set syntax-table properties on characters that would otherwise
856 ;; interact syntactically with those outside the CPP line(s). 861 ;; interact syntactically with those outside the CPP line(s).
@@ -867,11 +872,12 @@ Note that the style variables are always made local to the buffer."
867 ;; Note: SPEED _MATTERS_ IN THIS FUNCTION!!! 872 ;; Note: SPEED _MATTERS_ IN THIS FUNCTION!!!
868 ;; 873 ;;
869 ;; This function might make hidden buffer changes. 874 ;; This function might make hidden buffer changes.
870 (c-save-buffer-state (limits mbeg+1 beg end) 875 (c-save-buffer-state (limits mbeg+1)
871 ;; First determine the region, (beg end), which may need "neutralizing". 876 ;; First determine the region, (c-new-BEG c-new-END), which will get font
872 ;; This may not start inside a string, comment, or macro. 877 ;; locked. It might need "neutralizing". This region may not start
878 ;; inside a string, comment, or macro.
873 (goto-char c-old-BOM) ; already set to old start of macro or begg. 879 (goto-char c-old-BOM) ; already set to old start of macro or begg.
874 (setq beg 880 (setq c-new-BEG
875 (if (setq limits (c-literal-limits)) 881 (if (setq limits (c-literal-limits))
876 (cdr limits) ; go forward out of any string or comment. 882 (cdr limits) ; go forward out of any string or comment.
877 (point))) 883 (point)))
@@ -881,16 +887,17 @@ Note that the style variables are always made local to the buffer."
881 (goto-char (car limits))) ; go backward out of any string or comment. 887 (goto-char (car limits))) ; go backward out of any string or comment.
882 (if (c-beginning-of-macro) 888 (if (c-beginning-of-macro)
883 (c-end-of-macro)) 889 (c-end-of-macro))
884 (setq end (max (+ (- c-old-EOM old-len) (- endd begg)) 890 (setq c-new-END (max (+ (- c-old-EOM old-len) (- endd begg))
885 (point))) 891 (point)))
886 892
887 ;; Clear all old punctuation properties 893 ;; Clear any existing punctuation properties.
888 (c-clear-char-property-with-value beg end 'syntax-table '(1)) 894 (c-clear-char-property-with-value c-new-BEG c-new-END 'syntax-table '(1))
889 895
890 (goto-char beg) 896 ;; Add needed properties to each CPP construct in the region.
891 (let ((pps-position beg) pps-state) 897 (goto-char c-new-BEG)
892 (while (and (< (point) end) 898 (let ((pps-position c-new-BEG) pps-state)
893 (search-forward-regexp c-anchored-cpp-prefix end t)) 899 (while (and (< (point) c-new-END)
900 (search-forward-regexp c-anchored-cpp-prefix c-new-END t))
894 ;; If we've found a "#" inside a string/comment, ignore it. 901 ;; If we've found a "#" inside a string/comment, ignore it.
895 (setq pps-state 902 (setq pps-state
896 (parse-partial-sexp pps-position (point) nil nil pps-state) 903 (parse-partial-sexp pps-position (point) nil nil pps-state)
@@ -978,6 +985,8 @@ Note that the style variables are always made local to the buffer."
978 (buffer-substring-no-properties type-pos term-pos) 985 (buffer-substring-no-properties type-pos term-pos)
979 (buffer-substring-no-properties beg end))))))) 986 (buffer-substring-no-properties beg end)))))))
980 987
988 ;; (c-new-BEG c-new-END) will be the region to fontify. It may become
989 ;; larger than (beg end).
981 (setq c-new-BEG beg 990 (setq c-new-BEG beg
982 c-new-END end) 991 c-new-END end)
983 (if c-get-state-before-change-function 992 (if c-get-state-before-change-function
@@ -1048,7 +1057,6 @@ This does not load the font-lock package. Use after
1048 nil nil 1057 nil nil
1049 ,c-identifier-syntax-modifications 1058 ,c-identifier-syntax-modifications
1050 c-beginning-of-syntax 1059 c-beginning-of-syntax
1051 (font-lock-lines-before . 1)
1052 (font-lock-mark-block-function 1060 (font-lock-mark-block-function
1053 . c-mark-function))) 1061 . c-mark-function)))
1054 1062
@@ -1063,8 +1071,9 @@ This does not load the font-lock package. Use after
1063 ;; font-lock-extend-after-change-region-function, is forced to use advice 1071 ;; font-lock-extend-after-change-region-function, is forced to use advice
1064 ;; instead. 1072 ;; instead.
1065 ;; 1073 ;;
1066 ;; Of the seven CC Mode languages, currently (2008-04) only AWK Mode makes 1074 ;; Of the seven CC Mode languages, currently (2009-05) only C, C++, Objc
1067 ;; non-null use of this function. 1075 ;; (the languages with #define) and AWK Mode make non-null use of this
1076 ;; function.
1068 (cons c-new-BEG c-new-END)) 1077 (cons c-new-BEG c-new-END))
1069 1078
1070 1079