diff options
author | Alan Mackenzie <acm@muc.de> | 2011-10-27 20:34:23 +0000 |
---|---|---|
committer | Alan Mackenzie <acm@muc.de> | 2011-10-27 20:34:23 +0000 |
commit | 536610a433e6edc0b3f831272c4e0424ebebee46 (patch) | |
tree | fcb6f43d840d6fd67d20b64ba4e510ddee34ae45 /lisp/progmodes/cc-defs.el | |
parent | 86c606818495d9411fd5d6b1477f9a097eb18020 (diff) | |
download | emacs-536610a433e6edc0b3f831272c4e0424ebebee46.tar.gz emacs-536610a433e6edc0b3f831272c4e0424ebebee46.tar.bz2 emacs-536610a433e6edc0b3f831272c4e0424ebebee46.zip |
Amend to indent and fontify macros "which include their own semicolon"
correctly, using the "virtual semicolon" mechanism.
cc-defs.el: Update "virtual semicolon" comments.
cc-engine.el (c-crosses-statement-barrier-p): Recoded to scan one line at
at time rather than having \n and \r explicitly in c-stmt-delim-chars
(for some modes, e.g. AWK).
(c-forward-label): Amend for virtual semicolons.
(c-at-macro-vsemi-p, c-macro-vsemi-status-unknown-p): New functions
cc-fonts.el (c-font-lock-declarations): Take account of the new C macros.
cc-langs.el (c-at-vsemi-p-fn, c-vsemi-status-unknown-p-fn): move to
earlier in the file.
(c-opt-cpp-symbol, c-line-comment-start-regexp): New language variables.
(c-opt-cpp-macro-define): Make into a full language variable.
(c-stmt-delim-chars, c-stmt-delim-chars-with-comma): Special value for
AWK Mode (including \n, \r) removed, no longer needed.
cc-mode.el (c-mode, c++-mode, objc-mode): Invoke
c-make-macro-with-semi-re.
cc-vars.el (c-macro-with-semi-re, c-macro-names-with-semicolon): New
variables.
(c-make-macro-with-semi-re): New function
cc-mode.texi (Indentation Commands): Mention "macros with semicolons".
(Other Special Indentations): Add an xref to "Macros with ;".
(Customizing Macros): Add stuff about syntax in macros. Add an xref to
"Macros with ;".
(Macros with ;): New page.
Diffstat (limited to 'lisp/progmodes/cc-defs.el')
-rw-r--r-- | lisp/progmodes/cc-defs.el | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/lisp/progmodes/cc-defs.el b/lisp/progmodes/cc-defs.el index e5b4d7e35a4..93da6e3e2be 100644 --- a/lisp/progmodes/cc-defs.el +++ b/lisp/progmodes/cc-defs.el @@ -744,19 +744,20 @@ be after it." ;; V i r t u a l S e m i c o l o n s ;; ;; In most CC Mode languages, statements are terminated explicitly by -;; semicolons or closing braces. In some of the CC modes (currently only AWK -;; Mode (April 2004)), statements are (or can be) terminated by EOLs. Such a -;; statement is said to be terminated by a "virtual semicolon" (VS). A -;; statement terminated by an actual semicolon or brace is never considered to -;; have a VS. +;; semicolons or closing braces. In some of the CC modes (currently AWK Mode +;; and certain user-specified #define macros in C, C++, etc. (November 2008)), +;; statements are (or can be) terminated by EOLs. Such a statement is said to +;; be terminated by a "virtual semicolon" (VS). A statement terminated by an +;; actual semicolon or brace is never considered to have a VS. ;; ;; The indentation engine (or whatever) tests for a VS at a specific position ;; by invoking the macro `c-at-vsemi-p', which in its turn calls the mode ;; specific function (if any) which is the value of the language variable -;; `c-at-vsemi-p-fn'. The actual details of what constitutes a VS in a -;; language are thus encapsulated in code specific to that language -;; (e.g. cc-awk.el). `c-at-vsemi-p' returns non-nil if point (or the optional -;; parameter POS) is at a VS, nil otherwise. +;; `c-at-vsemi-p-fn'. This function should only use "low-level" features of +;; CC Mode, i.e. features which won't trigger infinite recursion. ;-) The +;; actual details of what constitutes a VS in a language are thus encapsulated +;; in code specific to that language (e.g. cc-awk.el). `c-at-vsemi-p' returns +;; non-nil if point (or the optional parameter POS) is at a VS, nil otherwise. ;; ;; The language specific function might well do extensive analysis of the ;; source text, and may use a cacheing scheme to speed up repeated calls. |