diff options
| author | Alan Mackenzie | 2008-02-19 22:11:38 +0000 |
|---|---|---|
| committer | Alan Mackenzie | 2008-02-19 22:11:38 +0000 |
| commit | 5ee2e9881b707eed5b3f2f5a07b2e20fac001759 (patch) | |
| tree | 5b388794127286c5efa1ec81f7672c50ec412eda | |
| parent | 2ae6c6b5f3bd0d42e0df6ffa0cd8c8cf8ba99c64 (diff) | |
| download | emacs-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.el | 54 |
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'." | |||
| 414 | classifies symbol constituents like '_' and '$' as word constituents, | 414 | classifies symbol constituents like '_' and '$' as word constituents, |
| 415 | so that all identifiers are recognized as words.") | 415 | so 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. | ||
| 419 | Typically it will record enough state to allow | ||
| 420 | `c-before-font-lock-function' to extend the region to fontify, | ||
| 421 | and may do such things as removing text-properties which must be | ||
| 422 | recalculated. | ||
| 423 | |||
| 424 | It takes 2 parameters, the BEG and END supplied to every | ||
| 425 | before-change function; on entry, the buffer will have been | ||
| 426 | widened and match-data will have been saved; point is undefined | ||
| 427 | on both entry and exit; the return value is ignored. | ||
| 428 | |||
| 429 | When the mode is initialized, this function is called with | ||
| 430 | parameters \(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. | ||
| 439 | Typically it will extend the region about to be fontified \(see | ||
| 440 | below) and will set `syntax-table' text properties on the region. | ||
| 441 | |||
| 442 | It takes 3 parameters, the BEG, END, and OLD-LEN supplied to | ||
| 443 | every after-change function; point is undefined on both entry and | ||
| 444 | exit; on entry, the buffer will have been widened and match-data | ||
| 445 | will have been saved; the return value is ignored. | ||
| 446 | |||
| 447 | The function may extend the region to be fontified by setting the | ||
| 448 | buffer local variables c-old-BEG and c-old-LEN. | ||
| 449 | |||
| 450 | The function is called even when font locking is disabled. | ||
| 451 | |||
| 452 | When the mode is initialized, this function is called with | ||
| 453 | parameters \(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, | ||
| 693 | in 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 |
| 650 | name, or nil in languages without preprocessor support. The first | 700 | name, or nil in languages without preprocessor support. The first |
| @@ -662,7 +712,7 @@ submatch surrounds the directive name." | |||
| 662 | string message." | 712 | string 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 |
| 704 | expression." | 754 | expression." |
| 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"))) |