aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Mackenzie2008-02-19 22:11:38 +0000
committerAlan Mackenzie2008-02-19 22:11:38 +0000
commit5ee2e9881b707eed5b3f2f5a07b2e20fac001759 (patch)
tree5b388794127286c5efa1ec81f7672c50ec412eda
parent2ae6c6b5f3bd0d42e0df6ffa0cd8c8cf8ba99c64 (diff)
downloademacs-5ee2e9881b707eed5b3f2f5a07b2e20fac001759.tar.gz
emacs-5ee2e9881b707eed5b3f2f5a07b2e20fac001759.zip
Set of changes so that "obtrusive" syntactic elements in a
C/C++/ObjC preprocessor line (e.g. an unbalanced string quote or unmatched paren) don't interact syntactically with stuff outside the CPP line. (c-get-state-before-change-function, c-before-font-lock-function, c-anchored-cpp-prefix): new language variables. (c-cpp-message-directives): Handle "#warning" in C, C++ and ObjC.
-rw-r--r--lisp/progmodes/cc-langs.el54
1 files changed, 52 insertions, 2 deletions
diff --git a/lisp/progmodes/cc-langs.el b/lisp/progmodes/cc-langs.el
index 54725c0fd88..c2a3c68e2c4 100644
--- a/lisp/progmodes/cc-langs.el
+++ b/lisp/progmodes/cc-langs.el
@@ -414,6 +414,49 @@ the new syntax, as accepted by `modify-syntax-entry'."
414classifies symbol constituents like '_' and '$' as word constituents, 414classifies symbol constituents like '_' and '$' as word constituents,
415so that all identifiers are recognized as words.") 415so that all identifiers are recognized as words.")
416 416
417(c-lang-defconst c-get-state-before-change-function
418 "If non-nil, a function called from c-before-change-hook.
419Typically it will record enough state to allow
420`c-before-font-lock-function' to extend the region to fontify,
421and may do such things as removing text-properties which must be
422recalculated.
423
424It takes 2 parameters, the BEG and END supplied to every
425before-change function; on entry, the buffer will have been
426widened and match-data will have been saved; point is undefined
427on both entry and exit; the return value is ignored.
428
429When the mode is initialized, this function is called with
430parameters \(point-min) and \(point-max)."
431 t nil
432 (c c++ objc) 'c-extend-region-for-CPP
433 awk 'c-awk-record-region-clear-NL)
434(c-lang-defvar c-get-state-before-change-function
435 (c-lang-const c-get-state-before-change-function))
436
437(c-lang-defconst c-before-font-lock-function
438 "If non-nil, a function called just before font locking.
439Typically it will extend the region about to be fontified \(see
440below) and will set `syntax-table' text properties on the region.
441
442It takes 3 parameters, the BEG, END, and OLD-LEN supplied to
443every after-change function; point is undefined on both entry and
444exit; on entry, the buffer will have been widened and match-data
445will have been saved; the return value is ignored.
446
447The function may extend the region to be fontified by setting the
448buffer local variables c-old-BEG and c-old-LEN.
449
450The function is called even when font locking is disabled.
451
452When the mode is initialized, this function is called with
453parameters \(point-min), \(point-max) and <buffer size>."
454 t nil
455 (c c++ objc) 'c-neutralize-syntax-in-CPP
456 awk 'c-awk-extend-and-syntax-tablify-region)
457(c-lang-defvar c-before-font-lock-function
458 (c-lang-const c-before-font-lock-function))
459
417 460
418;;; Lexer-level syntax (identifiers, tokens etc). 461;;; Lexer-level syntax (identifiers, tokens etc).
419 462
@@ -645,6 +688,13 @@ Assumed to not contain any submatches or \\| operators."
645 (java awk) nil) 688 (java awk) nil)
646(c-lang-defvar c-opt-cpp-prefix (c-lang-const c-opt-cpp-prefix)) 689(c-lang-defvar c-opt-cpp-prefix (c-lang-const c-opt-cpp-prefix))
647 690
691(c-lang-defconst c-anchored-cpp-prefix
692 "Regexp matching the prefix of a cpp directive anchored to BOL,
693in the languages that have a macro preprocessor."
694 t (if (c-lang-const c-opt-cpp-prefix)
695 (concat "^" (c-lang-const c-opt-cpp-prefix))))
696(c-lang-defvar c-anchored-cpp-prefix (c-lang-const c-anchored-cpp-prefix))
697
648(c-lang-defconst c-opt-cpp-start 698(c-lang-defconst c-opt-cpp-start
649 "Regexp matching the prefix of a cpp directive including the directive 699 "Regexp matching the prefix of a cpp directive including the directive
650name, or nil in languages without preprocessor support. The first 700name, or nil in languages without preprocessor support. The first
@@ -662,7 +712,7 @@ submatch surrounds the directive name."
662string message." 712string message."
663 t (if (c-lang-const c-opt-cpp-prefix) 713 t (if (c-lang-const c-opt-cpp-prefix)
664 '("error")) 714 '("error"))
665 pike '("error" "warning")) 715 (c c++ objc pike) '("error" "warning"))
666 716
667(c-lang-defconst c-cpp-include-directives 717(c-lang-defconst c-cpp-include-directives
668 "List of cpp directives (without the prefix) that are followed by a 718 "List of cpp directives (without the prefix) that are followed by a
@@ -700,7 +750,7 @@ definition, or nil if the language doesn't have any."
700 (c-lang-const c-opt-cpp-macro-define-id)) 750 (c-lang-const c-opt-cpp-macro-define-id))
701 751
702(c-lang-defconst c-cpp-expr-directives 752(c-lang-defconst c-cpp-expr-directives
703 "List if cpp directives (without the prefix) that are followed by an 753 "List of cpp directives (without the prefix) that are followed by an
704expression." 754expression."
705 t (if (c-lang-const c-opt-cpp-prefix) 755 t (if (c-lang-const c-opt-cpp-prefix)
706 '("if" "elif"))) 756 '("if" "elif")))