mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-04-27 08:43:40 -07:00
CC Mode update to version 5.29. This is for testing; it's not a released
version.
This commit is contained in:
parent
9211d05383
commit
a66cd3ee16
12 changed files with 6548 additions and 3217 deletions
890
lisp/ChangeLog
890
lisp/ChangeLog
|
|
@ -1,3 +1,893 @@
|
|||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-mode.el: (c-define-abbrev-table): New function to
|
||||
pass the SYSTEM-FLAG to `define-abbrev' in a way that works in
|
||||
emacsen that doesn't support it.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-align.el, progmodes/cc-engine.el,
|
||||
progmodes/cc-styles.el, progmodes/cc-vars.el
|
||||
(c-guess-basic-syntax, c-lineup-topmost-intro-cont): Find
|
||||
correct anchor for statement-cont in top level constructs.
|
||||
Analyze variable initializations in top level constructs as
|
||||
topmost-intro-cont instead of statement-cont. That is an
|
||||
incompatible change but it gives better consistency. The new
|
||||
lineup function c-lineup-topmost-intro-cont' compensates for
|
||||
it and is now put on topmost-intro-cont by default.
|
||||
|
||||
* progmodes/cc-align.el, progmodes/cc-engine.el,
|
||||
progmodes/cc-langs.el (c-lineup-argcont): Lineup function
|
||||
contributed by Kevin Ryde.
|
||||
|
||||
(c-in-gcc-asm-p): Function to recognize asm statements.
|
||||
Contributed by Kevin Ryde.
|
||||
|
||||
(c-opt-asm-stmt-key): New language variable to recognize the
|
||||
beginning of asm statements.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-engine.el (c-guess-basic-syntax): Detect
|
||||
variable declarations after class and struct declarations
|
||||
correctly. Fixed limit error when finding the anchor for
|
||||
template-args-cont and topmost-intro-cont.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el (c-beginning-of-defun,
|
||||
c-declaration-limits): Find the "line oriented" declaration
|
||||
start too, just like the "line oriented" end is found.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-vars.el (c-offsets-alist): A more sane default
|
||||
for `inexpr-statement'. This is not compatible, though. I
|
||||
think the benefit of a good default style outweights that in
|
||||
this case. Besides, `inexpr-statement' is not very common.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el (c-electric-delete-forward): Fixed
|
||||
silly bug that caused it to delete backwards in hungry delete
|
||||
mode. (It's amazing that this bug hasn't been reported.)
|
||||
|
||||
* progmodes/cc-cmds.el (c-declaration-limits, c-mark-function):
|
||||
Extracted the code to get the declaration limits from
|
||||
`c-mark-function' to a new `c-declaration-limits'.
|
||||
|
||||
(c-indent-defun): Use the same method to get the limits of the
|
||||
declaration or macro as `c-mark-function'.
|
||||
|
||||
* progmodes/cc-engine.el (c-beginning-of-decl-1): Handle brace
|
||||
list initializers correctly (but costly; it ought to be
|
||||
integrated into `c-beginning-of-statement-1').
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el, progmodes/cc-engine.el
|
||||
(c-beginning-of-defun, c-end-of-defun, c-mark-function):
|
||||
Rewritten to detect the declaration limits better. Now
|
||||
handles K&R argdecls, class definitions followed by variables
|
||||
etc.
|
||||
|
||||
(c-in-knr-argdecl): Broke out the K&R argdecl test in
|
||||
`c-beginning-of-decl-1' to this new function.
|
||||
|
||||
(c-end-of-statement-1, c-end-of-decl-1): Replaced
|
||||
`c-end-of-statement-1' with `c-end-of-decl-1', which correctly
|
||||
handles declarations that continue after the block.
|
||||
|
||||
* progmodes/cc-engine.el (c-syntactic-re-search-forward):
|
||||
Added an option to restrict matching to the top level of the
|
||||
current paren sexp.
|
||||
|
||||
* progmodes/cc-langs.el (c-opt-block-decls-with-vars-key): New
|
||||
regexp to recognize declarations that continue after the
|
||||
block.
|
||||
|
||||
(c-syntactic-eol): New regexp to match a "syntactic" eol.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-engine.el (c-guess-basic-syntax): Fixed a bug
|
||||
that often caused the backward limit to be lost at the top
|
||||
level. This improves performance a bit.
|
||||
|
||||
* progmodes/cc-engine.el (c-syntactic-re-search-forward): New
|
||||
function that works like `re-search-forward' but only returns
|
||||
matches in syntactically significant text.
|
||||
|
||||
* progmodes/cc-engine.el: Fixed a faster and more accurate way
|
||||
to recognize K&R argdecls.
|
||||
|
||||
(c-beginning-of-decl-1): New function that put point at the
|
||||
beginning of the declaration. It handles K&R argdecl blocks.
|
||||
|
||||
(c-guess-basic-syntax): Replaced the `knr-argdecl' recognition
|
||||
code with one that doesn't depend on the current indentation.
|
||||
The anchor position for `knr-argdecl' has also changed, but in
|
||||
a way that is unlikely to cause compatibility problems.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-defs.el, progmodes/cc-engine.el
|
||||
(c-forward-comment): `forward-comment' in XEmacs skips over
|
||||
line continuations in the backward direction. Correct for
|
||||
that. Also made this a defun since it has grown too large now
|
||||
to be a defsubst.
|
||||
|
||||
* progmodes/cc-langs.el: More convenient and decentralized
|
||||
setup of the language specific variables. The regexp-opt
|
||||
mangling is also done at compile time now.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el (c-indent-line-or-region): Call
|
||||
`c-indent-line' directly instead of through
|
||||
`indent-according-to-mode' so that this function always
|
||||
indents syntactically.
|
||||
|
||||
* progmodes/cc-engine.el (c-guess-basic-syntax): Fixed a bug
|
||||
where a class beginning with a nested class could cause an
|
||||
infinite loop (the state outside the narrowed out class is
|
||||
never used now).
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-align.el, progmodes/cc-cmds.el,
|
||||
progmodes/cc-engine.el, progmodes/cc-vars.el: Fixes so that
|
||||
the context sensitive analysis inside macros is restricted to
|
||||
the bodies of #define's; other things, like #if expressions,
|
||||
never have anything in common with their surroundings. The
|
||||
old `cpp-macro-cont' syntax is now used in situations where
|
||||
the syntactic analysis isn't applicable, and a new syntactic
|
||||
element `cpp-define-intro' is used to add indentation in
|
||||
#define bodies.
|
||||
|
||||
(c-lineup-cpp-define): New name for `c-lineup-macro-cont' to
|
||||
better reflect its use.
|
||||
|
||||
* progmodes/cc-engine.el (c-guess-basic-syntax): Ignore line
|
||||
continuation backslashes in the detection of
|
||||
`arglist-cont-nonempty'.
|
||||
|
||||
* progmodes/cc-align.el: Use the vector form in the return
|
||||
value in all cases where lineup functions return absolute
|
||||
columns.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-engine.el (c-add-stmt-syntax,
|
||||
c-guess-basic-syntax): Anchor `brace-list-intro' and
|
||||
`bracec-list-close' better for brace lists nested inside
|
||||
expressions.
|
||||
|
||||
* progmodes/cc-engine.el, progmodes/cc-langs.el,
|
||||
progmodes/cc-mode.el, progmodes/cc-styles.el: Cleaned up the
|
||||
various language specific variables and their initialization.
|
||||
The keyword regexps are now lists that are combined with
|
||||
regexp-opt. Some variables have changed names to fit better
|
||||
with the naming convention.
|
||||
|
||||
* progmodes/cc-defs.el, progmodes/cc-vars.el
|
||||
(c-buffer-is-cc-mode): The value is the mode symbol of the
|
||||
original CC Mode mode.
|
||||
|
||||
(c-major-mode-is): Compare against the buffer local variable
|
||||
`c-buffer-is-cc-mode', which is faster than using
|
||||
`derived-mode-class'.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-engine.el (c-forward-syntactic-ws,
|
||||
c-backward-syntactic-ws, c-forward-token-1,
|
||||
c-backward-token-1, c-in-literal, c-literal-limits,
|
||||
c-collect-line-comments, c-literal-type, c-on-identifier,
|
||||
c-guess-basic-syntax): These functions are now considered part
|
||||
of the "CC Mode API" and may be used by other code. That's
|
||||
signified by making their documentation into docstrings.
|
||||
|
||||
(c-whack-state, c-hack-state, c-skip-case-statement-forward):
|
||||
Removed these internal functions since they aren't used.
|
||||
|
||||
(c-forward-to-cpp-expression): Classified this function as
|
||||
internal.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-langs.el (c-ObjC-class-key, c-Java-class-key):
|
||||
Simplified these regexps; the class keywords they contain
|
||||
ought to be enough to avoid false matches, so checking for
|
||||
following identifiers etc is just unnecessary (and might also
|
||||
fail for oddly formatted code).
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-engine.el, progmodes/cc-cmds.el
|
||||
(c-forward-comment-lc): New function that behaves like
|
||||
`c-forward-comment', with the exception that line
|
||||
continuations are treated as whitespace.
|
||||
|
||||
(c-beginning-of-statement): Use `c-forward-comment-lc', to
|
||||
work correctly in macros and other places where line
|
||||
continuations should be treated as whitespace.
|
||||
|
||||
* progmodes/cc-engine.el (c-guess-basic-syntax): Analyze a
|
||||
normal label in a switch block as a case label, to get
|
||||
consistent lineup with the case labels.
|
||||
|
||||
* progmodes/cc-engine.el (c-backward-syntactic-ws): Fixed bug
|
||||
in skipping over a macro that ends with an empty line.
|
||||
|
||||
* progmodes/cc-styles.el: Require cc-align since styles added
|
||||
with `c-add-style' often contains references to functions
|
||||
defined there, and so the `c-valid-offset' check might
|
||||
otherwise complain on them.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-align.el, progmodes/cc-mode.texi,
|
||||
progmodes/cc-vars.el: Added two new lineup functions:
|
||||
|
||||
(c-lineup-knr-region-comment): A new lineup function to get
|
||||
(what most people think is) better indentation of comments in
|
||||
the "K&R region" between the function header and its body.
|
||||
|
||||
(c-lineup-gcc-asm-reg): New lineup function for better
|
||||
indentation inside gcc asm blocks. Contributed by Kevin Ryde.
|
||||
|
||||
(c-offsets-alist): Use `c-lineup-gcc-asm-reg' and
|
||||
`c-lineup-knr-region-comment' in the default offset
|
||||
configuration, since these two functions have little impact
|
||||
outside their intended use, and they generally do the right
|
||||
thing when they kick in.
|
||||
|
||||
* progmodes/cc-engine.el (c-guess-continued-construct,
|
||||
c-guess-basic-syntax): Handle nested functions in all
|
||||
languages, not just Pike. In C and C++ there's a gcc
|
||||
extension for this, and it also gives better treatment of
|
||||
macros that are followed by blocks.
|
||||
|
||||
* progmodes/cc-langs.el (c-symbol-key): Made this variable
|
||||
mode specific, to handle Pike special symbols like `== better.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el, progmodes/cc-engine.el,
|
||||
progmodes/cc-vars.el (c-report-syntactic-errors): A new
|
||||
variable to control the syntactic error messages. It defaults
|
||||
to off; since CC Mode ignores most syntactic errors it might
|
||||
as well ignore them all for the sake of consistency.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-engine.el (c-looking-at-inexpr-block):
|
||||
Optimization. Can give a noticeable speedup if there's a
|
||||
large preceding function or class body.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-align.el, progmodes/cc-cmds.el: Use more
|
||||
efficient and correct insertion functions in many places.
|
||||
Always inherit text properties correctly if the text is
|
||||
permanent. Also do it for speed in temporary insertions,
|
||||
since I figure it's less work to continue the surrounding text
|
||||
properties than to break them.
|
||||
|
||||
* progmodes/cc-styles.el (c-read-offset): Unbind SPC in the
|
||||
completion to make it easier to enter lists.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el (c-beginning-of-defun): Fixed bug where
|
||||
c-state-cache was clobbered.
|
||||
|
||||
* progmodes/cc-cmds.el, progmodes/cc-engine.el
|
||||
(c-calculate-state): Moved from cc-cmds.el to cc-engine.el due
|
||||
to dependency.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-engine.el (c-parse-state): Ignore unbalanced
|
||||
open parens in macros (if point isn't in the same one).
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el (c-context-open-line): New function
|
||||
that is the `open-line' equivalent to `c-context-line-break'.
|
||||
|
||||
* progmodes/cc-mode.el (c-mode-base-map): Compatibility fix
|
||||
for Emacs 21 since `indent-new-comment-line' has been changed
|
||||
to `comment-indent-new-line' there.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-engine.el, progmodes/cc-langs.el
|
||||
(c-stmt-delim-chars, c-stmt-delim-chars-with-comma): New
|
||||
variables containing the character sets used to recognize
|
||||
statement/declaration boundaries. These variables might help
|
||||
to support languages like javascript and awk, where newlines
|
||||
sometimes delimits statements.
|
||||
|
||||
(c-crosses-statement-barrier-p): Use `c-stmt-delim-chars' as
|
||||
the set of statement delimiting characters, to allow it to be
|
||||
changed dynamically and per-mode.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-engine.el (c-looking-at-bos,
|
||||
c-looking-at-inexpr-block, c-add-stmt-syntax,
|
||||
c-guess-basic-syntax): Treat blocks directly inside function
|
||||
calls like "bare" statements inside function calls, and not
|
||||
like in-expression statements. This to make indentation of
|
||||
such blocks consistent with other statements inside macro
|
||||
calls.
|
||||
|
||||
* progmodes/cc-engine.el (c-guess-basic-syntax): Made
|
||||
arglist-cont anchor correctly in arglists that contain
|
||||
statements.
|
||||
|
||||
* progmodes/cc-engine.el (c-guess-basic-syntax): Fixed
|
||||
consistent anchoring of defun-block-intro in defuns in code
|
||||
blocks (can only occur in Pike).
|
||||
|
||||
* progmodes/cc-engine.el (c-looking-at-inexpr-block,
|
||||
c-looking-at-inexpr-block-backward): Changed the arguments to
|
||||
require containing sexps and paren state, for better
|
||||
efficiency.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el, progmodes/cc-engine.el,
|
||||
progmodes/cc-vars.el: Improved anchoring of statement and
|
||||
handling of labels in front of substatements.
|
||||
|
||||
(c-guess-continued-construct, c-guess-basic-syntax): Improved
|
||||
and unified anchoring at statements. Statements beginning
|
||||
with comments or labels are now avoided, by going out of
|
||||
blocks and containing statements if necessary. This nesting
|
||||
handling also fixes the case when there's a statement after a
|
||||
block open brace. Added the syntactic symbol
|
||||
`substatement-label'.
|
||||
|
||||
(c-electric-colon): Map the new `substatement-label' to
|
||||
`label' when consulting `c-hanging-colons-alist'.
|
||||
|
||||
(c-offsets-alist): Added substatement-label. Updated the
|
||||
comments for the new anchoring positions at statements.
|
||||
|
||||
* progmodes/cc-engine.el (c-guess-basic-syntax): Use more sane
|
||||
anchor points for knr-argdecl-intro and access-label. They
|
||||
used to refer to some point on the same line, a bug which was
|
||||
neutralized by a kludge in `c-get-syntactic-indentation' which
|
||||
ignored such anchor points.
|
||||
|
||||
(c-get-syntactic-indentation): Removed the kludge that was
|
||||
necessary due to buggy anchor points.
|
||||
|
||||
* progmodes/cc-engine.el (c-guess-basic-syntax): Do not check
|
||||
the absence of a comma before arglist-close (case 7A) in any
|
||||
language, since there's nothing better to do that case anyway.
|
||||
Added special case to make in-expression statements be
|
||||
recognized as normal arglist-cont if we're directly in a macro
|
||||
arglist, for consistency with other "bare" statements.
|
||||
|
||||
* progmodes/cc-engine.el (c-looking-at-bos): Added optional
|
||||
limit arg for backward searches.
|
||||
|
||||
* progmodes/cc-engine.el (c-looking-at-inexpr-block): Anchor
|
||||
gcc in-expression statements at the surrounding open
|
||||
parenthesis. Treat a class body as an in-expression class if
|
||||
it's used in an object clone expression in Pike.
|
||||
|
||||
* progmodes/cc-engine.el (c-get-offset,
|
||||
c-get-syntactic-indentation): Allow several anchor positions
|
||||
in the list of syntactic symbols. Only the first is used as
|
||||
the base for the offset calculation.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el (c-indent-defun): Indent the current
|
||||
macro if inside one at the top level. Do not throw an error
|
||||
if used at the top level outside a macro.
|
||||
|
||||
* progmodes/cc-cmds.el (c-backslash-region): Do tab width
|
||||
alignment only if the backslashes can't be aligned with
|
||||
surrounding backslashes.
|
||||
|
||||
* progmodes/cc-engine.el (c-end-of-macro): New function.
|
||||
|
||||
* progmodes/cc-engine.el (c-least-enclosing-brace): Rewritten
|
||||
to not be destructive.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el (c-context-line-break): Only do a macro
|
||||
line break when point is inside the content of it; if it's in
|
||||
the cpp keyword a normal line break is done.
|
||||
|
||||
* progmodes/cc-engine.el (c-guess-basic-syntax): Do not add
|
||||
cpp-macro-cont inside the argument list to a #define.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-defs.el (c-forward-comment): Implemented a
|
||||
kludge to avoid the problem most forward-comment incarnations
|
||||
have with `\' together with comment parsing.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-engine.el (c-check-state-cache): Fixed bug
|
||||
which could cause the state returned by `c-parse-state' to
|
||||
lack a closed paren element. That in turn could result in
|
||||
very long searches, since it's common that they start from the
|
||||
last preceding close brace.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-engine.el (c-beginning-of-statement-1): Do not
|
||||
treat else-if as a single continuation, since that'd make it
|
||||
hard to get the right anchor point when there's a line break
|
||||
between the two keywords. This change causes else-clause to
|
||||
be anchored on the closest preceding else-if and not always on
|
||||
the starting if, but that doesn't affect the indentation for
|
||||
any reasonably sane style. Also introduced a noerror flag.
|
||||
|
||||
(c-beginning-of-closest-statement): Removed;
|
||||
c-beginning-of-statement-1 now avoids the problem this one
|
||||
solved.
|
||||
|
||||
* progmodes/cc-engine.el (c-guess-continued-construct,
|
||||
c-guess-basic-syntax): Better and more uniform anchor points
|
||||
for 'statement-cont and 'substatement. The effect is
|
||||
noticeable mostly when there's a label on the same line as the
|
||||
beginning of the statement, or when there are more stuff
|
||||
before the start of the statement.
|
||||
|
||||
* progmodes/cc-engine.el (c-looking-at-inexpr-block): Added
|
||||
flag to disable looking at the type of the surrounding paren
|
||||
since that confuses c-beginning-of-statement-1 and a couple of
|
||||
other places.
|
||||
|
||||
* progmodes/cc-engine.el (c-guess-basic-syntax): Avoid
|
||||
stepping to the previous statement in case 18. Improvements
|
||||
in recognition of statement blocks on the top level.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-engine.el (c-beginning-of-statement-1,
|
||||
c-crosses-statement-barrier-p): Rewritten to get a well
|
||||
defined and documented behavior. This fixes some tricky cases
|
||||
in recognition of do-while constructs.
|
||||
|
||||
(c-backward-to-start-of-do, c-backward-to-start-of-if):
|
||||
Removed; use c-beginning-of-statement-1 instead.
|
||||
|
||||
(c-guess-continued-construct, c-guess-basic-syntax): Various
|
||||
fixes to not depend on the bugs previously in
|
||||
c-beginning-of-statement-1. Cleanups in cases 18 and 17 to
|
||||
use the new behavior of c-beginning-of-statement-1 better.
|
||||
Fixed recognition of catch blocks inside macros.
|
||||
|
||||
* progmodes/cc-engine.el (c-backward-syntactic-ws): Fixed bug
|
||||
in skipping over a macro.
|
||||
|
||||
* progmodes/cc-langs.el (c-label-kwds): New variable to
|
||||
contain the appropriate c-*-label-kwds value.
|
||||
|
||||
* progmodes/cc-vars.el (defcustom-c-stylevar): Fixed value
|
||||
evaluation bug that caused the widget for
|
||||
c-block-comment-prefix to bug out.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-engine.el (c-guess-basic-syntax): Improved
|
||||
recognition of statements: They are now recognized in contexts
|
||||
where they normally can't occur, e.g. on the top level or in
|
||||
function call arguments. This is mainly useful to recognize
|
||||
statements in macros at the top level, and in arguments to
|
||||
macros. The cases has been moved around quite a bit, and case
|
||||
10 has been copied to case 18. (The cases has not been
|
||||
renumbered because of this.)
|
||||
|
||||
(c-guess-continued-construct): New function which has the
|
||||
rules which are common between cases 10 and 18.
|
||||
|
||||
* progmodes/cc-engine.el (c-beginning-of-statement-1,
|
||||
c-backward-to-start-of-do, c-backward-to-start-of-if): Fixes
|
||||
so that they really obey the passed limits.
|
||||
|
||||
(c-safe-position): Return nil if the state doesn't contain a
|
||||
suitable position.
|
||||
|
||||
(c-guess-basic-syntax): Fixes some too short limits in calls
|
||||
to c-beginning-of-statement-1. Some fixes for top level
|
||||
analysis in ObjC mode.
|
||||
|
||||
* progmodes/cc-engine.el (c-beginning-of-statement-1): Fixed
|
||||
bug in do-while statements where the body is not a block.
|
||||
|
||||
* progmodes/cc-styles.el (c-set-style): Reset
|
||||
c-special-indent-hook to its global value if in override mode.
|
||||
Fixes problem where functions on that hook remained after
|
||||
style switch.
|
||||
|
||||
* progmodes/cc-engine.el (c-evaluate-offset, c-get-offset):
|
||||
Use c-benign-error to report the c-strict-syntax-p error.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-align.el, progmodes/cc-defs.el,
|
||||
progmodes/cc-cmds.el, progmodes/cc-engine.el, cc-vars.el:
|
||||
Several fixes to treat macros as code and not literals and to
|
||||
handle line continuations transparently.
|
||||
|
||||
(c-skip-ws-forward, c-skip-ws-backward): New macros to skip
|
||||
through whitespace and line continuations, but not comments
|
||||
and macros.
|
||||
|
||||
(c-in-literal): No longer recognizes macros as literals by
|
||||
default. An extra flag argument is required to do that.
|
||||
|
||||
(c-macro-start, c-query-macro-start,
|
||||
c-query-and-set-macro-start): Added a cache for the macro
|
||||
start position.
|
||||
|
||||
(c-forward-syntactic-ws, c-backward-syntactic-ws): Fixes for
|
||||
more speed when limits are given. Workaround for bad behavior
|
||||
in forward-comment in some emacsen when it hits a buffer limit
|
||||
with a large repeat count.
|
||||
|
||||
(c-lineup-macro-cont): Improved behavior when
|
||||
c-syntactic-indentation-in-macros is nil.
|
||||
|
||||
(c-syntactic-indentation-in-macros, c-backslash-max-column,
|
||||
c-auto-align-backslashes): New customization variables to
|
||||
control macro handling.
|
||||
|
||||
* progmodes/cc-menus.el (cc-imenu-c++-generic-expression):
|
||||
Fixes to handle line continuations.
|
||||
|
||||
* progmodes/cc-defs.el, progmodes/cc-styles.el
|
||||
(c-get-style-variables, c-set-offset): Report style errors
|
||||
with message and ding instead of error signal. This to avoid
|
||||
interrupted mode init if there's some style problem.
|
||||
|
||||
(c-benign-error): New macro to report errors that doesn't need
|
||||
to interrupt the operation.
|
||||
|
||||
* progmodes/cc-defs.el (c-point): Added eonl and eopl
|
||||
positions.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el (c-electric-brace, c-indent-region):
|
||||
Removed most of the c-state-cache fiddling, since the global
|
||||
state cache now handles this.
|
||||
|
||||
* progmodes/cc-engine.el (c-guess-basic-syntax): Fixed bug
|
||||
when there's an open paren at the very first char of the
|
||||
visible buffer region.
|
||||
|
||||
* progmodes/cc-engine.el (c-parse-state, c-check-state-cache):
|
||||
Cache the state globally and invalidate it below every buffer
|
||||
change with the new after change function
|
||||
`c-check-state-cache'. This gives a considerable performance
|
||||
boost when editing large functions or classes.
|
||||
|
||||
* progmodes/cc-engine.el (c-whack-state-after): Slight
|
||||
optimization.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-engine.el, progmodes/cc-langs.el,
|
||||
progmodes/cc-align.el: Improvements to syntactic analysis
|
||||
inside macros:
|
||||
|
||||
(c-block-stmt-1-kwds, c-block-stmt-2-kwds): New variables used
|
||||
by `c-guess-basic-syntax'.
|
||||
|
||||
(c-parse-state): Fixed bug with braces inside macros when
|
||||
using cached state info.
|
||||
|
||||
(c-forward-to-cpp-expression): New function to aid in
|
||||
syntactic analysis inside macros.
|
||||
|
||||
(c-beginning-of-statement-1, c-backward-syntactic-ws): Fixes
|
||||
to work better inside macros.
|
||||
|
||||
(c-forward-syntactic-ws): Whitespace between the # and the
|
||||
command should be allowed in preprocessor directives.
|
||||
|
||||
(c-lineup-macro-cont): New lineup function to get context
|
||||
sensitive indentation inside macros.
|
||||
|
||||
(c-offsets-alist): Made `c-lineup-macro-cont' the default for
|
||||
cpp-macro-cont.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-engine.el (c-beginning-of-statement-1,
|
||||
c-forward-syntactic-ws): Fixes to handle continued lines.
|
||||
|
||||
(c-backward-to-start-of-if, c-guess-basic-syntax): Do
|
||||
syntactic analysis inside macros.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el (c-indent-region): Did a speedup made
|
||||
possible by the more flexible state cache.
|
||||
|
||||
* progmodes/cc-engine.el (c-parse-state, c-whack-state-before,
|
||||
c-whack-state-after, c-hack-state,
|
||||
c-narrow-out-enclosing-class, c-guess-basic-syntax): Improved
|
||||
the state cache system. It now can use partial info from an
|
||||
old cached state to calculate a new one at a different
|
||||
position. Removed some kludges to avoid the state cache. The
|
||||
new functions `c-whack-state-before' and `c-whack-state-after'
|
||||
replace the now obsolete `c-whack-state'.
|
||||
|
||||
* progmodes/cc-engine.el (c-beginning-of-statement-1):
|
||||
Optimized backing through a macro. This can speed things up
|
||||
quite a bit when there are long macros before point.
|
||||
|
||||
(c-beginning-of-macro): Do not ignore the limit.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el (c-electric-continued-statement): Fixed
|
||||
a bug where the keyword wasn't reindented correctly if
|
||||
followed by another keyword or identifier.
|
||||
|
||||
* progmodes/cc-engine.el (c-parse-state): Ignore closed brace
|
||||
pairs that are in macros. Fixes some cases where e.g. the
|
||||
second of two "do { } while (0)" macros after each other
|
||||
indented differently.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-engine.el (c-beginning-of-macro,
|
||||
c-forward-syntactic-ws): Recognize "#!" as a preprocessor
|
||||
directive when it begins a line, to allow for script
|
||||
interpreter lines like "#!/usr/bin/pike" at the beginning of
|
||||
the file.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-engine.el (c-looking-at-inexpr-block):
|
||||
Recognize brace blocks inside a parenthesis expression as
|
||||
inexpr-statement. Useful when writing statements as macro
|
||||
arguments.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el (c-fill-paragraph, c-do-auto-fill,
|
||||
c-mask-comment): Broke out the comment masking code from
|
||||
`c-fill-paragraph' to a new function `c-mask-comment', to be
|
||||
able to do the same thing in `c-do-auto-fill'. This should
|
||||
make auto-fill-mode behave better.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el (c-electric-brace, c-electric-paren):
|
||||
Check `executing-macro' to avoid blinking parens when macros
|
||||
are executed.
|
||||
|
||||
* progmodes/cc-mode.el, progmodes/cc-styles.el
|
||||
(c-setup-filladapt): Moved from cc-mode.el to cc-styles.el for
|
||||
consistency with `c-setup-paragraph-variables' (which was
|
||||
placed there due to the dependency from `c-set-style').
|
||||
|
||||
* progmodes/cc-styles.el, progmodes/cc-vars.el: Fixed bug with
|
||||
incomplete initialization from the style variable fallbacks if
|
||||
there already is a style called "user" defined when CC Mode
|
||||
starts up for the first time.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el, progmodes/cc-vars.el
|
||||
(c-comment-indent, c-indent-comment-alist): Added new variable
|
||||
`c-indent-comment-alist' to allow better control over
|
||||
`c-comment-indent'.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-align.el (c-lineup-C-comments): Try to match
|
||||
both `comment-start-skip' and the comment prefix on the
|
||||
current line with the comment starter, so that we line up
|
||||
comments which matches `c-comment-prefix-regexp' on the first
|
||||
line (after the `/') without the need to make
|
||||
`comment-start-skip' match whatever `c-comment-prefix-regexp'
|
||||
matches.
|
||||
|
||||
* progmodes/cc-mode.el, progmodes/cc-styles.el (c-common-init,
|
||||
c-set-style-1, c-setup-paragraph-variables): Moved the
|
||||
variable initialization based on `c-comment-prefix-regexp' to
|
||||
a new function `c-setup-paragraph-variables', which is now
|
||||
used both at mode init and when a style that sets
|
||||
`c-comment-prefix-regexp' is activated.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-engine.el (c-beginning-of-member-init-list):
|
||||
Better handling of C++ template args to avoid confusion with
|
||||
`<' and `>' used as operators in member init expressions.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-engine.el (c-most-enclosing-brace,
|
||||
c-least-enclosing-brace): Added optional second arg to limit
|
||||
the search to before a certain point.
|
||||
|
||||
* progmodes/cc-engine.el (c-guess-basic-syntax): Fixed bug
|
||||
which could cause incorrect analysis if a cached state is used
|
||||
(usually only happens when an electric key reindents a line).
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-defs.el (c-forward-comment): More idiosyncrasy
|
||||
insulation. This time for XEmacs 21.
|
||||
|
||||
* progmodes/cc-engine.el, progmodes/cc-langs.el: Improved
|
||||
handling of inheritance lists:
|
||||
|
||||
(c-beginning-of-inheritance-list): Rewritten to use a more
|
||||
syntactically correct method that doesn't get confused by
|
||||
badly placed linebreaks and comments.
|
||||
|
||||
(c-guess-basic-syntax): Several fixes to the handling of
|
||||
inheritance lists in combination with templates. 'inher-intro
|
||||
is now anchored on the start of the class declaration and not
|
||||
the indentation of the current line. Switched places on cases
|
||||
5D.3 and 5D.4 and made them use more syntactically correct
|
||||
methods.
|
||||
|
||||
(c-inher-key): Removed since the code in
|
||||
`c-guess-basic-syntax' now uses token-based search.
|
||||
|
||||
* progmodes/cc-cmds.el, progmodes/cc-mode.el (c-mode-menu):
|
||||
Added a submenu to access some toggles.
|
||||
|
||||
(c-toggle-syntactic-indentation): New function to toggle the
|
||||
variable `c-syntactic-indentation'.
|
||||
|
||||
* progmodes/cc-styles.el (c-set-style): Improved the error
|
||||
message for incorrect offsets a bit.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el (c-indent-exp): Don't require that the
|
||||
sexp follows point immediately, instead find the closest
|
||||
following open paren that ends on another line.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-align.el (c-lineup-cascaded-calls): New
|
||||
indentation function.
|
||||
|
||||
* progmodes/cc-engine.el (c-beginning-of-macro): Bugfix for
|
||||
directives with whitespace between the '#' and the name.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-engine.el (c-forward-syntactic-ws,
|
||||
c-backward-syntactic-ws): Handle line continuations as
|
||||
whitespace. Don't move past a macro if that'd take us past
|
||||
the limit.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-engine.el (c-beginning-of-macro,
|
||||
c-forward-syntactic-ws): Multiline strings begin with `#"' in
|
||||
Pike, and that shouldn't be confused with a preprocessor
|
||||
directive.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el: Extended the kludge to interoperate
|
||||
with the delsel and pending-del packages wrt to the new
|
||||
function `c-electric-delete-forward'.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el (c-indent-exp): Keep the indentation of
|
||||
the block itself, i.e. only indent the contents in it.
|
||||
|
||||
* progmodes/cc-styles.el (c-set-style): Use the default
|
||||
argument to completing-read instead of initial-contents, if
|
||||
the function is recent enough to support it.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-mode.el (c-mode-help-address): Removed
|
||||
bug-gnu-emacs@gnu.org from the receiver list for bug reports.
|
||||
I've almost never seen a bug reported this way that should go
|
||||
to that list, but it's rather common that the reports concern
|
||||
the combination CC Mode and XEmacs instead.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el (c-electric-paren): Fixed bug when both
|
||||
brace-elseif-brace and brace-catch-brace are active and
|
||||
there's a "else if"-block before the catch block.
|
||||
|
||||
* progmodes/cc-menus.el (cc-imenu-c++-generic-expression):
|
||||
Detect function headers that span lines.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el (c-electric-brace,
|
||||
c-electric-semi&comma, c-electric-colon, c-electric-paren):
|
||||
Check for last on line only for doing the auto-newline-mode
|
||||
stuff, not for the reindentation.
|
||||
|
||||
* progmodes/cc-cmds.el (c-electric-brace): Fixed bugs in the
|
||||
handling of c-syntactic-indentation: When it's nil, indent the
|
||||
new lines but don't reindent the current one. Reindent the
|
||||
line only when the inserted brace comes first on it, instead
|
||||
of last.
|
||||
|
||||
* progmodes/cc-cmds.el (c-electric-brace,
|
||||
c-electric-semi&comma): Fixed two places where
|
||||
c-syntactic-indentation wasn't heeded.
|
||||
|
||||
* progmodes/cc-cmds.el (c-electric-pound): Don't be electric
|
||||
inside a macro.
|
||||
|
||||
* progmodes/cc-engine.el (c-backward-to-start-of-if): Try a
|
||||
little harder to find a fallback position when an orphan else
|
||||
is found. Fixed case where an else following a do-while
|
||||
statement could be associated with an if inside the do-while.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el (c-guess-fill-prefix): Tuned the dwim
|
||||
for the fallback to add a single space after the comment
|
||||
prefix.
|
||||
|
||||
* progmodes/cc-cmds.el (c-indent-new-comment-line): Somewhat
|
||||
better behavior in some special cases, especially for
|
||||
single-line comments. Avoid breaking up a comment starter or
|
||||
ender.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el (c-outline-level): Applied patch from
|
||||
the Emacs sources to make this work in invisible text.
|
||||
|
||||
* progmodes/cc-langs.el (c-switch-label-key): Fixed regexp to
|
||||
not be confused by a later ':' on the same line as the label.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el, progmodes/cc-mode.el
|
||||
(c-electric-delete, c-electric-delete-forward): Split
|
||||
`c-electric-delete' into two functions where
|
||||
`c-electric-delete-forward' always deletes forward and
|
||||
`c-electric-delete' only contains the code necessary for
|
||||
XEmacs to choose between backward and forward deletion.
|
||||
`c-electric-delete-forward' is now bound to C-d to get the
|
||||
electric behavior on that key too.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-cmds.el (c-fill-paragraph): Fixed bogus direct
|
||||
use of c-comment-prefix-regexp, which caused an error when
|
||||
it's a list.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-mode.el, progmodes/cc-vars.el (c-common-init,
|
||||
c-default-style): Removed the hardcoded switch to "java" style
|
||||
in Java mode. It's instead taken care of by the default value
|
||||
for c-default-style.
|
||||
|
||||
2002-04-22 Martin Stjernholm <bug-cc-mode@gnu.org>
|
||||
|
||||
* progmodes/cc-align.el (c-lineup-math): Fix bug where lineup
|
||||
was triggered by equal signs in string literals.
|
||||
|
||||
2002-04-21 Kim F. Storm <storm@cua.dk>
|
||||
|
||||
* subr.el (insert-buffer-substring-no-properties): New function.
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program; see the file COPYING. If not, write to
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to
|
||||
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
|
|
@ -49,47 +49,107 @@
|
|||
|
||||
;; Standard indentation line-ups
|
||||
|
||||
(defun c-lineup-topmost-intro-cont (langelem)
|
||||
"Line up declaration continuation lines zero or one indentation step.
|
||||
For lines in the \"header\" of a definition, zero is used. For other
|
||||
lines, `c-basic-offset' is added to the indentation. E.g:
|
||||
|
||||
int
|
||||
neg (int i) <- c-lineup-topmost-intro-cont
|
||||
{
|
||||
return -i;
|
||||
}
|
||||
|
||||
struct
|
||||
larch <- c-lineup-topmost-intro-cont
|
||||
{
|
||||
double height;
|
||||
}
|
||||
the_larch, <- c-lineup-topmost-intro-cont
|
||||
another_larch; <- c-lineup-topmost-intro-cont
|
||||
<--> c-basic-offset
|
||||
|
||||
struct larch
|
||||
the_larch, <- c-lineup-topmost-intro-cont
|
||||
another_larch; <- c-lineup-topmost-intro-cont
|
||||
|
||||
\(This function is mainly provided to mimic the behavior of CC Mode
|
||||
5.28 and earlier where this case wasn't handled consistently so that
|
||||
these lines could be analyzed as either topmost-intro-cont or
|
||||
statement-cont.)
|
||||
|
||||
Works with: topmost-intro-cont."
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(c-backward-syntactic-ws (cdr langelem))
|
||||
(if (memq (char-before) '(?} ?,))
|
||||
c-basic-offset)))
|
||||
|
||||
(defun c-lineup-arglist (langelem)
|
||||
"Line up the current argument line under the first argument.
|
||||
|
||||
Works with: arglist-cont-nonempty."
|
||||
Works with: arglist-cont-nonempty, arglist-close."
|
||||
(save-excursion
|
||||
(let* ((containing-sexp
|
||||
(save-excursion
|
||||
;; arglist-cont-nonempty gives relpos ==
|
||||
;; to boi of containing-sexp paren. This
|
||||
;; is good when offset is +, but bad
|
||||
;; when it is c-lineup-arglist, so we
|
||||
;; have to special case a kludge here.
|
||||
(if (memq (car langelem) '(arglist-intro arglist-cont-nonempty))
|
||||
(progn
|
||||
(beginning-of-line)
|
||||
(backward-up-list 1)
|
||||
(skip-chars-forward " \t" (c-point 'eol)))
|
||||
(goto-char (cdr langelem)))
|
||||
(point)))
|
||||
(langelem-col (c-langelem-col langelem t)))
|
||||
(if (save-excursion
|
||||
(beginning-of-line)
|
||||
(looking-at "[ \t]*)"))
|
||||
(progn (goto-char (match-end 0))
|
||||
(c-forward-sexp -1)
|
||||
(forward-char 1)
|
||||
(c-forward-syntactic-ws)
|
||||
(- (current-column) langelem-col))
|
||||
(goto-char containing-sexp)
|
||||
(or (eolp)
|
||||
(not (memq (char-after) '(?{ ?\( ?\[)))
|
||||
(let ((eol (c-point 'eol))
|
||||
(here (progn
|
||||
(forward-char 1)
|
||||
(skip-chars-forward " \t")
|
||||
(point))))
|
||||
(c-forward-syntactic-ws)
|
||||
(if (< (point) eol)
|
||||
(goto-char here))))
|
||||
(- (current-column) langelem-col)
|
||||
))))
|
||||
(beginning-of-line)
|
||||
(let ((containing-sexp (c-most-enclosing-brace (c-parse-state))))
|
||||
(goto-char (1+ containing-sexp))
|
||||
(let ((eol (c-point 'eol)))
|
||||
(c-forward-syntactic-ws)
|
||||
(when (< (point) eol)
|
||||
(goto-char (1+ containing-sexp))
|
||||
(skip-chars-forward " \t")))
|
||||
(vector (current-column)))))
|
||||
|
||||
;; Contributed by Kevin Ryde <user42@zip.com.au>.
|
||||
(defun c-lineup-argcont (elem)
|
||||
"Line up a continued argument.
|
||||
|
||||
foo (xyz, aaa + bbb + ccc
|
||||
+ ddd + eee + fff); <- c-lineup-argcont
|
||||
|
||||
Only continuation lines like this are touched, `nil' is returned on lines
|
||||
which are the start of an argument.
|
||||
|
||||
Within a gcc asm block, \":\" is recognised as an argument separator,
|
||||
but of course only between operand specifications, not in the expressions
|
||||
for the operands.
|
||||
|
||||
Works with: arglist-cont, arglist-cont-nonempty."
|
||||
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(let ((bol (point)))
|
||||
|
||||
;; Previous line ending in a comma means we're the start of an
|
||||
;; argument. This should quickly catch most cases not for us.
|
||||
(c-backward-syntactic-ws)
|
||||
(let ((c (char-before)))
|
||||
(unless (eq c ?,)
|
||||
|
||||
;; In a gcc asm, ":" on the previous line means the start of an
|
||||
;; argument. And lines starting with ":" are not for us, don't
|
||||
;; want them to indent to the preceding operand.
|
||||
(let ((gcc-asm (save-excursion
|
||||
(goto-char bol)
|
||||
(c-in-gcc-asm-p))))
|
||||
(unless (and gcc-asm
|
||||
(or (eq c ?:)
|
||||
(save-excursion
|
||||
(goto-char bol)
|
||||
(looking-at "[ \t]*:"))))
|
||||
|
||||
(c-lineup-argcont-scan (if gcc-asm ?:))
|
||||
(vector (current-column)))))))))
|
||||
|
||||
(defun c-lineup-argcont-scan (&optional other-match)
|
||||
;; Find the start of an argument, for `c-lineup-argcont'.
|
||||
(when (eq 0 (c-backward-token-1 1 t))
|
||||
(let ((c (char-after)))
|
||||
(if (or (eq c ?,) (eq c other-match))
|
||||
(progn
|
||||
(forward-char)
|
||||
(c-forward-syntactic-ws))
|
||||
(c-lineup-argcont-scan other-match)))))
|
||||
|
||||
(defun c-lineup-arglist-intro-after-paren (langelem)
|
||||
"Line up a line just after the open paren of the surrounding paren or
|
||||
|
|
@ -98,13 +158,10 @@ brace block.
|
|||
Works with: defun-block-intro, brace-list-intro,
|
||||
statement-block-intro, statement-case-intro, arglist-intro."
|
||||
(save-excursion
|
||||
(let ((langelem-col (c-langelem-col langelem t))
|
||||
(ce-curcol (save-excursion
|
||||
(beginning-of-line)
|
||||
(backward-up-list 1)
|
||||
(skip-chars-forward " \t" (c-point 'eol))
|
||||
(current-column))))
|
||||
(- ce-curcol langelem-col -1))))
|
||||
(beginning-of-line)
|
||||
(backward-up-list 1)
|
||||
(skip-chars-forward " \t" (c-point 'eol))
|
||||
(vector (1+ (current-column)))))
|
||||
|
||||
(defun c-lineup-arglist-close-under-paren (langelem)
|
||||
"Line up a closing paren line under the corresponding open paren.
|
||||
|
|
@ -114,12 +171,9 @@ brace-list-close, arglist-close, extern-lang-close, namespace-close
|
|||
\(for most of these, a zero offset will normally produce the same
|
||||
result, though)."
|
||||
(save-excursion
|
||||
(let ((langelem-col (c-langelem-col langelem t))
|
||||
(ce-curcol (save-excursion
|
||||
(beginning-of-line)
|
||||
(backward-up-list 1)
|
||||
(current-column))))
|
||||
(- ce-curcol langelem-col))))
|
||||
(beginning-of-line)
|
||||
(backward-up-list 1)
|
||||
(vector (current-column))))
|
||||
|
||||
(defun c-lineup-close-paren (langelem)
|
||||
"Line up the closing paren under its corresponding open paren if the
|
||||
|
|
@ -147,7 +201,7 @@ brace-list-close, arglist-close, extern-lang-close, namespace-close."
|
|||
(c-forward-syntactic-ws (c-point 'eol))
|
||||
(if (eolp)
|
||||
0
|
||||
(- opencol (c-langelem-col langelem t))))
|
||||
(vector opencol)))
|
||||
(error nil))))
|
||||
|
||||
(defun c-lineup-streamop (langelem)
|
||||
|
|
@ -155,10 +209,10 @@ brace-list-close, arglist-close, extern-lang-close, namespace-close."
|
|||
|
||||
Works with: stream-op."
|
||||
(save-excursion
|
||||
(let ((langelem-col (c-langelem-col langelem)))
|
||||
(re-search-forward "<<\\|>>" (c-point 'eol) 'move)
|
||||
(goto-char (match-beginning 0))
|
||||
(- (current-column) langelem-col))))
|
||||
(goto-char (cdr langelem))
|
||||
(re-search-forward "<<\\|>>" (c-point 'eol) 'move)
|
||||
(goto-char (match-beginning 0))
|
||||
(vector (current-column))))
|
||||
|
||||
(defun c-lineup-multi-inher (langelem)
|
||||
"Line up the classes in C++ multiple inheritance clauses and member
|
||||
|
|
@ -182,8 +236,8 @@ Works with: inher-cont, member-init-cont."
|
|||
(here (point))
|
||||
(char-after-ip (progn
|
||||
(skip-chars-forward " \t")
|
||||
(char-after)))
|
||||
(langelem-col (c-langelem-col langelem)))
|
||||
(char-after))))
|
||||
(if (cdr langelem) (goto-char (cdr langelem)))
|
||||
|
||||
;; This kludge is necessary to support both inher-cont and
|
||||
;; member-init-cont, since they have different anchor positions.
|
||||
|
|
@ -199,7 +253,7 @@ Works with: inher-cont, member-init-cont."
|
|||
(if (or (eolp)
|
||||
(looking-at c-comment-start-regexp))
|
||||
(c-forward-syntactic-ws here))
|
||||
(- (current-column) langelem-col)
|
||||
(vector (current-column))
|
||||
)))
|
||||
|
||||
(defun c-lineup-java-inher (langelem)
|
||||
|
|
@ -216,12 +270,12 @@ class Foo class Foo
|
|||
|
||||
Works with: inher-cont."
|
||||
(save-excursion
|
||||
(let ((langelem-col (c-langelem-col langelem)))
|
||||
(forward-word 1)
|
||||
(if (looking-at "[ \t]*$")
|
||||
c-basic-offset
|
||||
(c-forward-syntactic-ws)
|
||||
(- (current-column) langelem-col)))))
|
||||
(goto-char (cdr langelem))
|
||||
(forward-word 1)
|
||||
(if (looking-at "[ \t]*$")
|
||||
c-basic-offset
|
||||
(c-forward-syntactic-ws)
|
||||
(vector (current-column)))))
|
||||
|
||||
(defun c-lineup-java-throws (langelem)
|
||||
"Line up Java throws declarations.
|
||||
|
|
@ -246,10 +300,9 @@ Works with: func-decl-cont."
|
|||
(throw 'done t))))))
|
||||
(if throws
|
||||
(if (zerop (c-forward-token-1 1 nil (c-point 'eol)))
|
||||
(- (current-column) (c-langelem-col langelem))
|
||||
(vector (current-column))
|
||||
(back-to-indentation)
|
||||
(+ (- (current-column) (c-langelem-col langelem))
|
||||
c-basic-offset))
|
||||
(vector (+ (current-column) c-basic-offset)))
|
||||
c-basic-offset))))
|
||||
|
||||
(defun c-indent-one-line-block (langelem)
|
||||
|
|
@ -332,21 +385,33 @@ Works with: The `c' syntactic symbol."
|
|||
(if (looking-at c-current-comment-prefix)
|
||||
(- (match-end 0) (point))
|
||||
0)))
|
||||
(starterlen (save-excursion
|
||||
(goto-char (cdr langelem))
|
||||
(looking-at comment-start-skip)
|
||||
(- (save-excursion
|
||||
(goto-char (match-end 0))
|
||||
(skip-chars-backward " \t")
|
||||
(point))
|
||||
(or (match-end 1) (point))
|
||||
1))) ; Don't count the first '/'.
|
||||
(langelem-col (save-excursion (c-langelem-col langelem))))
|
||||
(starterlen
|
||||
;; Get the length of the comment starter, not including
|
||||
;; the first '/'. We check if the comment prefix matched
|
||||
;; on the current line matches the starter or if it
|
||||
;; matches comment-start-skip, and choose whichever is
|
||||
;; longest.
|
||||
(max (save-excursion
|
||||
(goto-char (1+ (cdr langelem)))
|
||||
(if (and (match-string 0)
|
||||
(looking-at (regexp-quote (match-string 0))))
|
||||
(- (match-end 0) (match-beginning 0))
|
||||
0))
|
||||
(save-excursion
|
||||
(goto-char (cdr langelem))
|
||||
(looking-at comment-start-skip)
|
||||
(- (or (match-end 1)
|
||||
(save-excursion
|
||||
(goto-char (match-end 0))
|
||||
(skip-chars-backward " \t")
|
||||
(point)))
|
||||
(point)
|
||||
1)))))
|
||||
(if (and (> starterlen 10) (zerop prefixlen))
|
||||
;; The comment has a long starter and the line doesn't have
|
||||
;; a nonempty comment prefix. Treat it as free form text
|
||||
;; and don't change the indentation.
|
||||
(- (current-column) langelem-col)
|
||||
(vector (current-column))
|
||||
(forward-line -1)
|
||||
(back-to-indentation)
|
||||
(if (>= (cdr langelem) (point))
|
||||
|
|
@ -356,11 +421,14 @@ Works with: The `c' syntactic symbol."
|
|||
;; starter.
|
||||
(progn
|
||||
(goto-char (match-end 0))
|
||||
(if (looking-at "\\([ \t]+\\).+$")
|
||||
;; Align with the text that hangs after the
|
||||
;; comment starter.
|
||||
(goto-char (match-end 1)))
|
||||
(- (current-column) langelem-col))
|
||||
;; The following should not be necessary, since
|
||||
;; comment-start-skip should match everything (i.e.
|
||||
;; typically whitespace) that leads up to the text.
|
||||
;;(if (looking-at "\\([ \t]+\\).+$")
|
||||
;; ;; Align with the text that hangs after the
|
||||
;; ;; comment starter.
|
||||
;; (goto-char (match-end 1)))
|
||||
(vector (current-column)))
|
||||
;; How long is the comment starter? if greater than the
|
||||
;; length of the comment prefix, align left. if less
|
||||
;; than or equal, align right. this should also pick up
|
||||
|
|
@ -368,10 +436,9 @@ Works with: The `c' syntactic symbol."
|
|||
(if (> starterlen prefixlen)
|
||||
(progn
|
||||
(goto-char (cdr langelem))
|
||||
(- (current-column) -1 langelem-col))
|
||||
(goto-char (match-end 0))
|
||||
(skip-chars-backward " \t")
|
||||
(- (current-column) prefixlen langelem-col)))
|
||||
(vector (1+ (current-column))))
|
||||
(goto-char (+ (cdr langelem) starterlen 1))
|
||||
(vector (- (current-column) prefixlen))))
|
||||
;; Not on the second line in the comment. If the previous
|
||||
;; line has a nonempty comment prefix, align with it.
|
||||
;; Otherwise, align with the previous nonempty line, but
|
||||
|
|
@ -389,7 +456,7 @@ Works with: The `c' syntactic symbol."
|
|||
;; Align with the comment starter rather than
|
||||
;; with the code before it.
|
||||
(goto-char (cdr langelem)))))
|
||||
(- (current-column) langelem-col))))))
|
||||
(vector (current-column)))))))
|
||||
|
||||
(defun c-lineup-comment (langelem)
|
||||
"Line up a comment start according to `c-comment-only-line-offset'.
|
||||
|
|
@ -416,6 +483,30 @@ Works with: comment-intro."
|
|||
-1000)) ;jam it against the left side
|
||||
))))
|
||||
|
||||
(defun c-lineup-knr-region-comment (langelem)
|
||||
"Line up a comment in the \"K&R region\" with the declaration.
|
||||
That is the region between the function or class header and the
|
||||
beginning of the block. E.g:
|
||||
|
||||
int main()
|
||||
/* This is the main function. */ <- c-lineup-knr-region-comment
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Return nil if called in any other situation, to be useful in list
|
||||
expressions.
|
||||
|
||||
Works with: comment-intro."
|
||||
(when (or (assq 'topmost-intro-cont c-syntactic-context)
|
||||
(assq 'func-decl-cont c-syntactic-context)
|
||||
(assq 'knr-argdecl-intro c-syntactic-context)
|
||||
(assq 'lambda-intro-cont c-syntactic-context))
|
||||
(save-excursion
|
||||
(beginning-of-line)
|
||||
(c-beginning-of-statement-1)
|
||||
(vector (current-column)))))
|
||||
|
||||
(defun c-lineup-runin-statements (langelem)
|
||||
"Line up statements when the first statement is on the same line as
|
||||
the block opening brace. E.g:
|
||||
|
|
@ -431,11 +522,11 @@ returned. This makes the function usable in list expressions.
|
|||
Works with: The `statement' syntactic symbol."
|
||||
(if (eq (char-after (cdr langelem)) ?{)
|
||||
(save-excursion
|
||||
(let ((langelem-col (c-langelem-col langelem)))
|
||||
(forward-char 1)
|
||||
(skip-chars-forward " \t")
|
||||
(unless (eolp)
|
||||
(- (current-column) langelem-col))))))
|
||||
(if (cdr langelem) (goto-char (cdr langelem)))
|
||||
(forward-char 1)
|
||||
(skip-chars-forward " \t")
|
||||
(unless (eolp)
|
||||
(vector (current-column))))))
|
||||
|
||||
(defun c-lineup-math (langelem)
|
||||
"Line up the current line after the equal sign on the first line in
|
||||
|
|
@ -443,7 +534,7 @@ the statement. If there isn't any, indent with `c-basic-offset'. If
|
|||
the current line contains an equal sign too, try to align it with the
|
||||
first one.
|
||||
|
||||
Works with: statement-cont."
|
||||
Works with: statement-cont, arglist-cont, arglist-cont-nonempty."
|
||||
(save-excursion
|
||||
(let ((equalp (save-excursion
|
||||
(goto-char (c-point 'boi))
|
||||
|
|
@ -453,8 +544,8 @@ Works with: statement-cont."
|
|||
(= (c-forward-token-1 1 t eol) 0))))
|
||||
(and (eq (char-after) ?=)
|
||||
(- (point) (c-point 'boi)))))
|
||||
(langelem-col (c-langelem-col langelem))
|
||||
donep)
|
||||
(if (cdr langelem) (goto-char (cdr langelem)))
|
||||
(while (and (not donep)
|
||||
(< (point) (c-point 'eol)))
|
||||
(skip-chars-forward "^=" (c-point 'eol))
|
||||
|
|
@ -475,9 +566,39 @@ Works with: statement-cont."
|
|||
(forward-char 1)
|
||||
(skip-chars-forward " \t")
|
||||
(setq equalp 0)))
|
||||
(- (current-column) equalp langelem-col))
|
||||
(vector (- (current-column) equalp)))
|
||||
)))
|
||||
|
||||
(defun c-lineup-cascaded-calls (langelem)
|
||||
"Line up \"cascaded calls\" under each other.
|
||||
If the line begins with \"->\" and the preceding line ends with one or
|
||||
more function calls preceded by \"->\", then the arrow is lined up with
|
||||
the first of those \"->\". E.g:
|
||||
|
||||
result = proc->add(17)->add(18)
|
||||
->add(19) + <- c-lineup-cascaded-calls
|
||||
offset; <- c-lineup-cascaded-calls (inactive)
|
||||
|
||||
In any other situation nil is returned to allow use in list
|
||||
expressions.
|
||||
|
||||
Works with: statement-cont, arglist-cont, arglist-cont-nonempty."
|
||||
(save-excursion
|
||||
(let ((bopl (c-point 'bopl)) col)
|
||||
(back-to-indentation)
|
||||
(when (and (looking-at "->")
|
||||
(= (c-backward-token-1 1 t bopl) 0)
|
||||
(eq (char-after) ?\()
|
||||
(= (c-backward-token-1 3 t bopl) 0)
|
||||
(looking-at "->"))
|
||||
(setq col (current-column))
|
||||
(while (and (= (c-backward-token-1 1 t bopl) 0)
|
||||
(eq (char-after) ?\()
|
||||
(= (c-backward-token-1 3 t bopl) 0)
|
||||
(looking-at "->"))
|
||||
(setq col (current-column)))
|
||||
(vector col)))))
|
||||
|
||||
(defun c-lineup-template-args (langelem)
|
||||
"Line up template argument lines under the first argument.
|
||||
To allow this function to be used in a list expression, nil is
|
||||
|
|
@ -490,7 +611,7 @@ Works with: template-args-cont."
|
|||
(backward-up-list 1)
|
||||
(if (and (eq (char-after) ?<)
|
||||
(zerop (c-forward-token-1 1 nil (c-point 'eol))))
|
||||
(- (current-column) (c-langelem-col langelem))))))
|
||||
(vector (current-column))))))
|
||||
|
||||
(defun c-lineup-ObjC-method-call (langelem)
|
||||
"Line up selector args as elisp-mode does with function args:
|
||||
|
|
@ -579,10 +700,20 @@ construct.
|
|||
Works with: inlambda, inexpr-statement, inexpr-class."
|
||||
(save-excursion
|
||||
(back-to-indentation)
|
||||
(let ((res (or (c-looking-at-inexpr-block)
|
||||
(if (c-safe (backward-up-list 1)
|
||||
(eq (char-after) ?{))
|
||||
(c-looking-at-inexpr-block)))))
|
||||
(let* ((paren-state (c-parse-state))
|
||||
(containing-sexp (c-most-enclosing-brace paren-state))
|
||||
(res (or (c-looking-at-inexpr-block
|
||||
(c-safe-position containing-sexp paren-state)
|
||||
containing-sexp)
|
||||
(and containing-sexp
|
||||
(progn (goto-char containing-sexp)
|
||||
(eq (char-after) ?{))
|
||||
(progn (setq containing-sexp
|
||||
(c-most-enclosing-brace paren-state
|
||||
(point)))
|
||||
(c-looking-at-inexpr-block
|
||||
(c-safe-position containing-sexp paren-state)
|
||||
containing-sexp))))))
|
||||
(when res
|
||||
(goto-char (cdr res))
|
||||
(- (current-column)
|
||||
|
|
@ -614,6 +745,134 @@ inextern-lang, innamespace."
|
|||
0
|
||||
c-basic-offset)))
|
||||
|
||||
(defun c-lineup-cpp-define (langelem)
|
||||
"Line up macro continuation lines according to the indentation of
|
||||
the construct preceding the macro. E.g:
|
||||
|
||||
v beg of preceding constr v beg of preceding constr
|
||||
int dribble() {
|
||||
const char msg[] = if (!running)
|
||||
\"Some text.\"; error(\"Not running!\");
|
||||
|
||||
#define X(A, B) \ #define X(A, B) \
|
||||
do { \ <-> do { \ <- c-lineup-cpp-define
|
||||
printf (A, B); \ printf (A, B); \
|
||||
} while (0) } while (0)
|
||||
|
||||
If `c-syntactic-indentation-in-macros' is non-nil, the function
|
||||
returns the relative indentation to the macro start line to allow
|
||||
accumulation with other offsets. E.g. in the following cases,
|
||||
cpp-define-intro is combined with the statement-block-intro that comes
|
||||
from the \"do {\" that hangs on the \"#define\" line:
|
||||
|
||||
int dribble() {
|
||||
const char msg[] = if (!running)
|
||||
\"Some text.\"; error(\"Not running!\");
|
||||
|
||||
#define X(A, B) do { \ #define X(A, B) do { \
|
||||
printf (A, B); \ <-> printf (A, B); \ <- c-lineup-cpp-define
|
||||
this->refs++; \ this->refs++; \
|
||||
} while (0) <-> } while (0) <- c-lineup-cpp-define
|
||||
|
||||
The relative indentation returned by `c-lineup-cpp-define' is zero and
|
||||
two, respectively, in these two examples. They are then added to the
|
||||
two column indentation that statement-block-intro gives in both cases
|
||||
here.
|
||||
|
||||
If the relative indentation is zero, then nil is returned instead.
|
||||
This useful in a list expression to specify the default indentation on
|
||||
the top level.
|
||||
|
||||
If `c-syntactic-indentation-in-macros' is nil then this function keeps
|
||||
the current indentation, except for empty lines \(ignoring the ending
|
||||
backslash) where it takes the indentation from the closest preceding
|
||||
nonempty line in the macro. If there's no such line in the macro then
|
||||
the indentation is taken from the construct preceding it, as described
|
||||
above.
|
||||
|
||||
Works with: cpp-define-intro."
|
||||
(let (offset)
|
||||
(if c-syntactic-indentation-in-macros
|
||||
;; Go to the macro start and do a syntactic analysis of it.
|
||||
;; Then remove the cpp-macro element it should contain and
|
||||
;; calculate the indentation it then would get.
|
||||
(save-excursion
|
||||
(c-beginning-of-macro)
|
||||
(setq offset (- (c-get-syntactic-indentation
|
||||
(delete '(cpp-macro) (c-guess-basic-syntax)))
|
||||
(save-excursion
|
||||
(back-to-indentation)
|
||||
(current-column))))
|
||||
(if (zerop offset)
|
||||
nil
|
||||
offset))
|
||||
;; Do not indent syntactically inside the macro.
|
||||
(save-excursion
|
||||
(let ((macro-start-line (save-excursion
|
||||
(goto-char (c-query-macro-start))
|
||||
(beginning-of-line)
|
||||
(point))))
|
||||
(beginning-of-line)
|
||||
;; Check every line while inside the macro.
|
||||
(while (and (> (point) macro-start-line)
|
||||
(looking-at "[ \t]*\\\\?$")
|
||||
(= (forward-line -1) 0)))
|
||||
(if (<= (point) macro-start-line)
|
||||
;; If we've stepped out of the macro we take the
|
||||
;; syntactic offset.
|
||||
(setq offset (c-get-syntactic-indentation
|
||||
(delete '(cpp-macro) (c-guess-basic-syntax))))
|
||||
(setq offset (current-indentation)))
|
||||
(if (zerop offset)
|
||||
nil
|
||||
(vector offset)))))))
|
||||
|
||||
;; Contributed by Kevin Ryde <user42@zip.com.au>.
|
||||
(defun c-lineup-gcc-asm-reg (elem)
|
||||
"Line up a gcc asm register under one on a previous line.
|
||||
|
||||
asm (\"foo %1, %0\\n\"
|
||||
\"bar %0, %1\"
|
||||
: \"=r\" (w),
|
||||
\"=r\" (x)
|
||||
: \"0\" (y),
|
||||
\"1\" (z));
|
||||
|
||||
The \"x\" line is aligned to the text after the \":\" on the \"w\" line, and
|
||||
similarly \"z\" under \"y\".
|
||||
|
||||
This is done only in an \"asm\" or \"__asm__\" block, and only to those
|
||||
lines mentioned. Anywhere else `nil' is returned. The usual arrangement is
|
||||
to have this routine as an extra feature at the start of arglist lineups, e.g.
|
||||
|
||||
(c-lineup-gcc-asm-reg c-lineup-arglist)
|
||||
|
||||
Works with: arglist-cont, arglist-cont-nonempty."
|
||||
|
||||
(let ((orig-pos (point))
|
||||
alignto)
|
||||
(save-excursion
|
||||
(and
|
||||
c-opt-asm-stmt-key
|
||||
|
||||
;; Find the ":" to align to. Look for this first so as to quickly
|
||||
;; eliminate pretty much all cases which are not for us.
|
||||
(re-search-backward "^[ \t]*:[ \t]*\\(.\\)?" (cdr elem) t)
|
||||
|
||||
;; Must have something after the ":".
|
||||
(setq alignto (match-beginning 1))
|
||||
|
||||
;; Don't touch ":" lines themselves.
|
||||
(progn (goto-char orig-pos)
|
||||
(beginning-of-line)
|
||||
(not (looking-at "^[ \t]*:")))
|
||||
|
||||
;; Only operate in an asm statement.
|
||||
(progn (goto-char orig-pos)
|
||||
(c-in-gcc-asm-p))
|
||||
|
||||
(vector (progn (goto-char alignto) (current-column)))))))
|
||||
|
||||
(defun c-lineup-dont-change (langelem)
|
||||
"Do not change the indentation of the current line.
|
||||
|
||||
|
|
@ -663,7 +922,7 @@ indentation amount."
|
|||
(setq syntax nil)
|
||||
(back-to-indentation)
|
||||
(if (zerop (current-column))
|
||||
(insert (make-string c-label-minimum-indentation 32)))
|
||||
(insert-char ?\ c-label-minimum-indentation t))
|
||||
))
|
||||
))))
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@
|
|||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to the
|
||||
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to
|
||||
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
;;; Commentary:
|
||||
|
|
@ -31,6 +31,10 @@
|
|||
;; compiled regardless the environment (e.g. if an older CC Mode with
|
||||
;; outdated macros are loaded during compilation). It also provides
|
||||
;; features to defeat the compiler warnings for selected symbols.
|
||||
;;
|
||||
;; There's really nothing CC Mode specific here; this functionality
|
||||
;; ought to be provided by the byte compilers or some accompanying
|
||||
;; library.
|
||||
|
||||
|
||||
;;; Code:
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -23,7 +23,7 @@
|
|||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program; see the file COPYING. If not, write to
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to
|
||||
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program; see the file COPYING. If not, write to
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to
|
||||
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
|
|
@ -57,6 +57,7 @@
|
|||
|
||||
;; Silence the compiler.
|
||||
(cc-bytecomp-defvar c-enable-xemacs-performance-kludge-p) ; In cc-vars.el
|
||||
(cc-bytecomp-defvar c-buffer-is-cc-mode) ; In cc-vars.el
|
||||
(cc-bytecomp-defun buffer-syntactic-context-depth) ; XEmacs
|
||||
(cc-bytecomp-defun region-active-p) ; XEmacs
|
||||
(cc-bytecomp-defvar zmacs-region-stays) ; XEmacs
|
||||
|
|
@ -83,13 +84,17 @@
|
|||
;; eol -- end of line
|
||||
;; bod -- beginning of defun
|
||||
;; eod -- end of defun
|
||||
;; boi -- back to indentation
|
||||
;; boi -- beginning of indentation
|
||||
;; ionl -- indentation of next line
|
||||
;; iopl -- indentation of previous line
|
||||
;; bonl -- beginning of next line
|
||||
;; eonl -- end of next line
|
||||
;; bopl -- beginning of previous line
|
||||
;; eopl -- end of previous line
|
||||
;;
|
||||
;; This function does not modify point or mark.
|
||||
;; If the referenced position doesn't exist, the closest accessible
|
||||
;; point to it is returned. This function does not modify point or
|
||||
;; mark.
|
||||
`(save-excursion
|
||||
,(if point `(goto-char ,point))
|
||||
,(if (and (eq (car-safe position) 'quote)
|
||||
|
|
@ -99,10 +104,16 @@
|
|||
((eq position 'bol) `(beginning-of-line))
|
||||
((eq position 'eol) `(end-of-line))
|
||||
((eq position 'boi) `(back-to-indentation))
|
||||
((eq position 'bod) `(c-beginning-of-defun-1))
|
||||
((eq position 'bonl) `(forward-line 1))
|
||||
((eq position 'bopl) `(forward-line -1))
|
||||
((eq position 'bod) `(c-beginning-of-defun-1))
|
||||
((eq position 'eod) `(c-end-of-defun-1))
|
||||
((eq position 'eopl) `(progn
|
||||
(beginning-of-line)
|
||||
(or (bobp) (backward-char))))
|
||||
((eq position 'eonl) `(progn
|
||||
(forward-line 1)
|
||||
(end-of-line)))
|
||||
((eq position 'iopl) `(progn
|
||||
(forward-line -1)
|
||||
(back-to-indentation)))
|
||||
|
|
@ -116,10 +127,16 @@
|
|||
((eq position 'bol) (beginning-of-line))
|
||||
((eq position 'eol) (end-of-line))
|
||||
((eq position 'boi) (back-to-indentation))
|
||||
((eq position 'bod) (c-beginning-of-defun-1))
|
||||
((eq position 'bonl) (forward-line 1))
|
||||
((eq position 'bopl) (forward-line -1))
|
||||
((eq position 'bod) (c-beginning-of-defun-1))
|
||||
((eq position 'eod) (c-end-of-defun-1))
|
||||
((eq position 'eopl) (progn
|
||||
(beginning-of-line)
|
||||
(or (bobp) (backward-char))))
|
||||
((eq position 'eonl) (progn
|
||||
(forward-line 1)
|
||||
(end-of-line)))
|
||||
((eq position 'iopl) (progn
|
||||
(forward-line -1)
|
||||
(back-to-indentation)))
|
||||
|
|
@ -134,6 +151,7 @@
|
|||
`(condition-case nil
|
||||
(progn ,@body)
|
||||
(error nil)))
|
||||
(put 'c-safe 'lisp-indent-function 0)
|
||||
|
||||
(defmacro c-forward-sexp (&optional arg)
|
||||
;; like forward-sexp except
|
||||
|
|
@ -153,29 +171,30 @@
|
|||
(or arg (setq arg 1))
|
||||
`(c-forward-sexp ,(if (numberp arg) (- arg) `(- ,arg))))
|
||||
|
||||
;; Wrappers for common scan-lists cases, mainly because it's almost
|
||||
;; impossible to get a feel for how that function works.
|
||||
(defmacro c-up-list-forward (pos)
|
||||
`(c-safe (scan-lists ,pos 1 1)))
|
||||
(defmacro c-up-list-backward (pos)
|
||||
`(c-safe (scan-lists ,pos -1 1)))
|
||||
(defmacro c-down-list-forward (pos)
|
||||
`(c-safe (scan-lists ,pos 1 -1)))
|
||||
(defmacro c-down-list-backward (pos)
|
||||
`(c-safe (scan-lists ,pos -1 -1)))
|
||||
|
||||
(defmacro c-add-syntax (symbol &optional relpos)
|
||||
;; a simple macro to append the syntax in symbol to the syntax list.
|
||||
;; try to increase performance by using this macro
|
||||
`(setq syntax (cons (cons ,symbol ,relpos) syntax)))
|
||||
`(let ((relpos-tmp ,relpos))
|
||||
(if relpos-tmp (setq syntactic-relpos relpos-tmp))
|
||||
(setq syntax (cons (cons ,symbol relpos-tmp) syntax))))
|
||||
|
||||
(defmacro c-add-class-syntax (symbol classkey)
|
||||
;; The inclass and class-close syntactic symbols are added in
|
||||
;; several places and some work is needed to fix everything.
|
||||
;; Therefore it's collected here. This is a macro mostly because
|
||||
;; c-add-syntax doesn't work otherwise.
|
||||
`(save-restriction
|
||||
(widen)
|
||||
(let ((symbol ,symbol)
|
||||
(classkey ,classkey)
|
||||
inexpr)
|
||||
(goto-char (aref classkey 1))
|
||||
(if (and (eq symbol 'inclass) (= (point) (c-point 'boi)))
|
||||
(c-add-syntax symbol (point))
|
||||
(c-add-syntax symbol (aref classkey 0))
|
||||
(if (and c-inexpr-class-key
|
||||
(setq inexpr (c-looking-at-inexpr-block))
|
||||
(/= (cdr inexpr) (c-point 'boi (cdr inexpr))))
|
||||
(c-add-syntax 'inexpr-class))))))
|
||||
(defmacro c-benign-error (format &rest args)
|
||||
;; Formats an error message for the echo area and dings, i.e. like
|
||||
;; `error' but doesn't abort.
|
||||
`(progn
|
||||
(message ,format ,@args)
|
||||
(ding)))
|
||||
|
||||
(defmacro c-update-modeline ()
|
||||
;; set the c-auto-hungry-string for the correct designation on the modeline
|
||||
|
|
@ -197,6 +216,66 @@
|
|||
(set-syntax-table c-with-syntax-table-orig-table))))
|
||||
(put 'c-with-syntax-table 'lisp-indent-function 1)
|
||||
|
||||
(defmacro c-skip-ws-forward (&optional limit)
|
||||
"Skip over any whitespace following point.
|
||||
This function skips over horizontal and vertical whitespace and line
|
||||
continuations."
|
||||
(if limit
|
||||
`(let ((-limit- (or ,limit (point-max))))
|
||||
(while (progn
|
||||
;; skip-syntax-* doesn't count \n as whitespace..
|
||||
(skip-chars-forward " \t\n\r\f" -limit-)
|
||||
(when (and (eq (char-after) ?\\)
|
||||
(< (point) -limit-))
|
||||
(forward-char)
|
||||
(or (eolp)
|
||||
(progn (backward-char) nil))))))
|
||||
'(while (progn
|
||||
(skip-chars-forward " \t\n\r\f")
|
||||
(when (eq (char-after) ?\\)
|
||||
(forward-char)
|
||||
(or (eolp)
|
||||
(progn (backward-char) nil)))))))
|
||||
|
||||
(defmacro c-skip-ws-backward (&optional limit)
|
||||
"Skip over any whitespace preceding point.
|
||||
This function skips over horizontal and vertical whitespace and line
|
||||
continuations."
|
||||
(if limit
|
||||
`(let ((-limit- (or ,limit (point-min))))
|
||||
(while (progn
|
||||
;; skip-syntax-* doesn't count \n as whitespace..
|
||||
(skip-chars-backward " \t\n\r\f" -limit-)
|
||||
(and (eolp)
|
||||
(eq (char-before) ?\\)
|
||||
(> (point) -limit-)))
|
||||
(backward-char)))
|
||||
'(while (progn
|
||||
(skip-chars-backward " \t\n\r\f")
|
||||
(and (eolp)
|
||||
(eq (char-before) ?\\)))
|
||||
(backward-char))))
|
||||
|
||||
;; Make edebug understand the macros.
|
||||
(eval-after-load "edebug"
|
||||
'(progn
|
||||
(def-edebug-spec c-paren-re t)
|
||||
(def-edebug-spec c-identifier-re t)
|
||||
(def-edebug-spec c-point ([&or symbolp form] &optional form))
|
||||
(def-edebug-spec c-safe t)
|
||||
(def-edebug-spec c-forward-sexp (&optional [&or numberp form]))
|
||||
(def-edebug-spec c-backward-sexp (&optional [&or numberp form]))
|
||||
(def-edebug-spec c-up-list-forward t)
|
||||
(def-edebug-spec c-up-list-backward t)
|
||||
(def-edebug-spec c-down-list-forward t)
|
||||
(def-edebug-spec c-down-list-backward t)
|
||||
(def-edebug-spec c-add-syntax t)
|
||||
(def-edebug-spec c-add-class-syntax t)
|
||||
(def-edebug-spec c-benign-error t)
|
||||
(def-edebug-spec c-with-syntax-table t)
|
||||
(def-edebug-spec c-skip-ws-forward t)
|
||||
(def-edebug-spec c-skip-ws-backward t)))
|
||||
|
||||
;;; Inline functions.
|
||||
|
||||
;; Note: All these after the macros, to be on safe side in avoiding
|
||||
|
|
@ -262,43 +341,6 @@
|
|||
(if (< (point) start)
|
||||
(goto-char (point-max)))))
|
||||
|
||||
(defsubst c-forward-comment (count)
|
||||
;; Insulation from various idiosyncrasies in implementations of
|
||||
;; `forward-comment'.
|
||||
;;
|
||||
;; Note: Some emacsen considers incorrectly that any line comment
|
||||
;; ending with a backslash continues to the next line. I can't
|
||||
;; think of any way to work around that in a reliable way without
|
||||
;; changing the buffer though. Suggestions welcome. ;)
|
||||
;;
|
||||
;; Another note: When moving backwards over a block comment, there's
|
||||
;; a bug in forward-comment that can make it stop at "/*" inside a
|
||||
;; line comment. Haven't yet found a reasonably cheap way to kludge
|
||||
;; around that one either. :\
|
||||
(let ((here (point)))
|
||||
(if (>= count 0)
|
||||
(when (forward-comment count)
|
||||
;; Emacs includes the ending newline in a b-style (c++)
|
||||
;; comment, but XEmacs doesn't. We depend on the Emacs
|
||||
;; behavior (which also is symmetric).
|
||||
(if (and (eolp) (nth 7 (parse-partial-sexp here (point))))
|
||||
(condition-case nil (forward-char 1)))
|
||||
t)
|
||||
;; When we got newline terminated comments,
|
||||
;; forward-comment in all supported emacsen so far will
|
||||
;; stop at eol of each line not ending with a comment when
|
||||
;; moving backwards. The following corrects for it when
|
||||
;; count is -1. The other common case, when count is
|
||||
;; large and negative, works regardless. It's too much
|
||||
;; work to correct for the rest of the cases.
|
||||
(skip-chars-backward " \t\n\r\f")
|
||||
(if (bobp)
|
||||
;; Some emacsen return t when moving backwards at bob.
|
||||
nil
|
||||
(re-search-forward "[\n\r]" here t)
|
||||
(if (forward-comment count)
|
||||
(if (eolp) (forward-comment -1) t))))))
|
||||
|
||||
(defsubst c-intersect-lists (list alist)
|
||||
;; return the element of ALIST that matches the first element found
|
||||
;; in LIST. Uses assq.
|
||||
|
|
@ -346,7 +388,7 @@
|
|||
(t (mark t))))
|
||||
|
||||
(defsubst c-major-mode-is (mode)
|
||||
(eq (derived-mode-class major-mode) mode))
|
||||
(eq c-buffer-is-cc-mode mode))
|
||||
|
||||
|
||||
(cc-provide 'cc-defs)
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -25,7 +25,7 @@
|
|||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program; see the file COPYING. If not, write to
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to
|
||||
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
|
|
@ -44,384 +44,585 @@
|
|||
(cc-require 'cc-defs)
|
||||
(cc-require 'cc-vars)
|
||||
|
||||
|
||||
(defvar c-buffer-is-cc-mode nil
|
||||
"Non-nil for all buffers with a `major-mode' derived from CC Mode.
|
||||
Otherwise, this variable is nil. I.e. this variable is non-nil for
|
||||
`c-mode', `c++-mode', `objc-mode', `java-mode', `idl-mode',
|
||||
`pike-mode', and any other non-CC Mode mode that calls
|
||||
`c-initialize-cc-mode' (e.g. `awk-mode').")
|
||||
(make-variable-buffer-local 'c-buffer-is-cc-mode)
|
||||
(put 'c-buffer-is-cc-mode 'permanent-local t)
|
||||
(require 'cl)
|
||||
|
||||
|
||||
;; Regular expressions and other values which must be parameterized on
|
||||
;; a per-language basis.
|
||||
;; Some support functions that are used when the language specific
|
||||
;; constants are built. Since the constants are built during compile
|
||||
;; time, these need to be defined then too.
|
||||
|
||||
;; Regex describing a `symbol' in all languages. We cannot use just
|
||||
;; `word' syntax class since `_' cannot be in word class. Putting
|
||||
;; underscore in word class breaks forward word movement behavior that
|
||||
;; users are familiar with. Besides, this runs counter to Emacs
|
||||
;; convention.
|
||||
(eval-and-compile
|
||||
;; `require' in XEmacs doesn't have the third NOERROR argument.
|
||||
(condition-case nil (require 'regexp-opt) (file-error nil))
|
||||
|
||||
(if (fboundp 'regexp-opt)
|
||||
(fset 'c-regexp-opt (symbol-function 'regexp-opt))
|
||||
;; Emacs 19.34 doesn't have the regexp-opt package.
|
||||
(defun c-regexp-opt (strings &optional paren)
|
||||
(if paren
|
||||
(concat "\\(" (mapconcat 'regexp-quote strings "\\|") "\\)")
|
||||
(mapconcat 'regexp-quote strings "\\|"))))
|
||||
|
||||
(if (fboundp 'regexp-opt-depth)
|
||||
(fset 'c-regexp-opt-depth (symbol-function 'regexp-opt-depth))
|
||||
;; Emacs 19.34 doesn't have the regexp-opt package.
|
||||
(defun c-regexp-opt-depth (regexp)
|
||||
;; This is the definition of `regexp-opt-depth' in Emacs 20.
|
||||
(save-match-data
|
||||
;; Hack to signal an error if REGEXP does not have balanced
|
||||
;; parentheses.
|
||||
(string-match regexp "")
|
||||
;; Count the number of open parentheses in REGEXP.
|
||||
(let ((count 0) start)
|
||||
(while (string-match "\\\\(" regexp start)
|
||||
(setq count (1+ count) start (match-end 0)))
|
||||
count))))
|
||||
|
||||
(defun c-make-keywords-re (adorn &rest lists)
|
||||
"Make a regexp that matches all the strings in all the lists.
|
||||
Duplicates in the lists are removed. The regexp may contain zero or
|
||||
more submatch expressions. If ADORN is non-nil there will be at least
|
||||
one submatch which matches the whole keyword, and the regexp will also
|
||||
not match a prefix of any identifier. Adorned regexps cannot be
|
||||
appended."
|
||||
(setq lists (delete-duplicates (apply 'append (nconc lists '(nil)))
|
||||
:test 'string-equal))
|
||||
(if lists
|
||||
(let ((re (c-regexp-opt lists)))
|
||||
;; Add our own grouping parenthesis around re instead of
|
||||
;; passing adorn to regexp-opt, since it in XEmacs makes the
|
||||
;; top level grouping "shy".
|
||||
(if adorn
|
||||
(concat "\\(" re "\\)\\>\\([^_]\\|$\\)")
|
||||
re))
|
||||
"\\<\\>" ; Matches nothing.
|
||||
))
|
||||
(put 'c-make-keywords-re 'lisp-indent-function 1)
|
||||
)
|
||||
|
||||
|
||||
;; Building of constants that are parameterized on a per-language
|
||||
;; basis.
|
||||
|
||||
(eval-and-compile
|
||||
(defvar c-macroexpand-mode nil
|
||||
;; Dynamically bound to the mode symbol during `c-lang-defconst'
|
||||
;; so that `c-lang-var' can do the right expansion.
|
||||
)
|
||||
|
||||
(defmacro c-lang-defconst (var &rest args)
|
||||
;; Sets the mode specific values of the constant VAR. The rest of
|
||||
;; the arguments are one or more repetitions of MODE VAL. MODE is
|
||||
;; the mode name without the "-mode" suffix, or a list of such
|
||||
;; mode names, or `all' as a shortcut for a list of all modes.
|
||||
;; VAL is evaluated (during compilation) for each mode with
|
||||
;; `c-macroexpand-mode' temporarily bound, so `c-lang-var' without
|
||||
;; an explicit mode may be used within it. The assignments in
|
||||
;; ARGS are processed in sequence, similar to `setq'.
|
||||
(let* ((res (list 'progn))
|
||||
(res-tail res))
|
||||
(while args
|
||||
(let ((mode (car args)))
|
||||
(cond ((eq mode 'all)
|
||||
(setq mode '(c c++ objc java idl pike)))
|
||||
((symbolp mode)
|
||||
(setq mode (list mode))))
|
||||
(while mode
|
||||
(let* ((c-macroexpand-mode
|
||||
(intern (concat (symbol-name (car mode)) "-mode")))
|
||||
(val (eval (car (cdr args)))))
|
||||
;; Need to install the value also during compilation,
|
||||
;; since val might refer to earlier mode specific
|
||||
;; values.
|
||||
(put var c-macroexpand-mode val)
|
||||
(setcdr res-tail (list `(put ',var ',c-macroexpand-mode ',val)))
|
||||
(setq res-tail (cdr res-tail)))
|
||||
(setq mode (cdr mode))))
|
||||
(setq args (cdr (cdr args))))
|
||||
res))
|
||||
(put 'c-lang-defconst 'lisp-indent-function 1)
|
||||
|
||||
(defmacro c-lang-var (var &optional mode)
|
||||
;; Get the mode specific value of the variable VAR in mode MODE.
|
||||
;; MODE is the mode name without the "-mode" suffix. It may also
|
||||
;; be nil to use the current value of `c-macroexpand-mode' (which
|
||||
;; is useful inside `c-lang-defconst') or `c-buffer-is-cc-mode'
|
||||
;; (which is useful inside `c-lang-defvar').
|
||||
`(get ',var ,(if (eq mode 'nil)
|
||||
(if c-macroexpand-mode
|
||||
;; In the macro expansion of c-lang-defconst.
|
||||
`(quote ,c-macroexpand-mode)
|
||||
`c-buffer-is-cc-mode)
|
||||
`(quote ,(intern (concat (symbol-name mode) "-mode"))))))
|
||||
|
||||
;; These are used to collect the init forms from the subsequent
|
||||
;; `c-lang-defvar'. They become a big setq in the
|
||||
;; `c-init-lang-defvars' lambda below.
|
||||
(defconst c-lang-defvar-init-form (list 'setq))
|
||||
(defconst c-lang-defvar-init-form-tail c-lang-defvar-init-form)
|
||||
|
||||
(defmacro c-lang-defvar (var val)
|
||||
;; Declares the buffer local variable VAR to get the value VAL at
|
||||
;; mode initialization, at which point VAL is evaluated.
|
||||
;; `c-lang-var' is typically used in VAL to get the right value
|
||||
;; according to `c-buffer-is-cc-mode'.
|
||||
(setcdr c-lang-defvar-init-form-tail (list var val))
|
||||
(setq c-lang-defvar-init-form-tail
|
||||
(cdr (cdr c-lang-defvar-init-form-tail)))
|
||||
`(progn
|
||||
(defvar ,var nil)
|
||||
(make-variable-buffer-local ',var)))
|
||||
(put 'c-lang-defvar 'lisp-indent-function 1)
|
||||
)
|
||||
|
||||
;; Regexp describing a `symbol' in all languages, not excluding
|
||||
;; keywords. We cannot use just `word' syntax class since `_' cannot
|
||||
;; be in word class. Putting underscore in word class breaks forward
|
||||
;; word movement behavior that users are familiar with. Besides, it
|
||||
;; runs counter to Emacs convention.
|
||||
;;
|
||||
;; I suspect this definition isn't correct in light of Java's
|
||||
;; definition of a symbol as being Unicode. I know so little about
|
||||
;; I18N (except how to sound cool and say I18N :-) that I'm willing to
|
||||
;; punt on this for now.
|
||||
(defconst c-symbol-key "[_a-zA-Z]\\(\\w\\|\\s_\\)*")
|
||||
;; This definition isn't correct for the first character in the
|
||||
;; languages that accept the full range of Unicode word constituents
|
||||
;; in identifiers (e.g. Java and Pike). For that we'd need to make a
|
||||
;; regexp that matches all characters in the word constituent class
|
||||
;; except 0-9, and the regexp engine currently can't do that.
|
||||
(c-lang-defconst c-symbol-key
|
||||
(c c++ objc java idl) "[_a-zA-Z]\\(\\w\\|\\s_\\)*"
|
||||
pike (concat "\\(" (c-lang-var c-symbol-key c) "\\|"
|
||||
(c-make-keywords-re nil
|
||||
'("`+" "`-" "`&" "`|" "`^" "`<<" "`>>" "`*" "`/" "`%" "`~"
|
||||
"`==" "`<" "`>" "`!" "`[]" "`[]=" "`->" "`->=" "`()" "``+"
|
||||
"``-" "``&" "``|" "``^" "``<<" "``>>" "``*" "``/" "``%"
|
||||
"`+="))
|
||||
"\\)"))
|
||||
(c-lang-defvar c-symbol-key (c-lang-var c-symbol-key))
|
||||
|
||||
;; Number of regexp grouping parens in c-symbol-key.
|
||||
(c-lang-defvar c-symbol-key-depth (c-regexp-opt-depth c-symbol-key))
|
||||
|
||||
(defvar c-stmt-delim-chars "^;{}?:")
|
||||
;; The characters that should be considered to bound statements. To
|
||||
;; optimize c-crosses-statement-barrier-p somewhat, it's assumed to
|
||||
;; begin with "^" to negate the set. If ? : operators should be
|
||||
;; detected then the string must end with "?:".
|
||||
|
||||
(defvar c-stmt-delim-chars-with-comma "^;,{}?:")
|
||||
;; Variant of c-stmt-delim-chars that additionally contains ','.
|
||||
|
||||
;; HELPME: Many of the following keyword lists are more or less bogus
|
||||
;; for some languages (notably ObjC and IDL). The effects of the
|
||||
;; erroneous values in the language handling is miniscule since these
|
||||
;; constants are not used very much (yet, anyway) in the actual syntax
|
||||
;; detection code, but I'd still appreciate help to get them correct.
|
||||
;; erroneous values in the language handling are mostly negligible
|
||||
;; since the constants that actually matter in the syntax detection
|
||||
;; code are mostly correct in the situations they are used, but I'd
|
||||
;; still appreciate help to get them correct for other uses.
|
||||
|
||||
;; Primitive type keywords.
|
||||
(defconst c-C-primitive-type-kwds
|
||||
"char\\|double\\|float\\|int\\|long\\|short\\|signed\\|unsigned\\|void")
|
||||
(defconst c-C++-primitive-type-kwds c-C-primitive-type-kwds)
|
||||
(defconst c-ObjC-primitive-type-kwds c-C-primitive-type-kwds)
|
||||
(defconst c-Java-primitive-type-kwds
|
||||
"boolean\\|byte\\|char\\|double\\|float\\|int\\|long\\|short\\|void")
|
||||
(defconst c-IDL-primitive-type-kwds c-C-primitive-type-kwds)
|
||||
(defconst c-Pike-primitive-type-kwds
|
||||
(concat "constant\\|float\\|int\\|mapping\\|multiset\\|object\\|"
|
||||
"program\\|string\\|void"))
|
||||
(c-lang-defconst c-primitive-type-kwds
|
||||
(c c++ objc idl) '("char" "double" "float" "int" "long" "short"
|
||||
"signed" "unsigned" "void")
|
||||
java '("boolean" "byte" "char" "double" "float" "int" "long" "short" "void")
|
||||
pike '("constant" "float" "int" "mapping" "multiset" "object" "program"
|
||||
"string" "void"))
|
||||
|
||||
;; Declaration specifier keywords.
|
||||
(defconst c-C-specifier-kwds
|
||||
"auto\\|const\\|extern\\|register\\|static\\|volatile")
|
||||
(defconst c-C++-specifier-kwds
|
||||
(concat c-C-specifier-kwds "\\|friend\\|inline\\|virtual"))
|
||||
(defconst c-ObjC-specifier-kwds c-C++-specifier-kwds)
|
||||
(defconst c-Java-specifier-kwds
|
||||
;; Note: `const' is not used, but it's still a reserved keyword.
|
||||
(concat "abstract\\|const\\|final\\|native\\|private\\|protected\\|"
|
||||
"public\\|static\\|synchronized\\|transient\\|volatile"))
|
||||
(defconst c-IDL-specifier-kwds c-C++-specifier-kwds)
|
||||
(defconst c-Pike-specifier-kwds
|
||||
(concat "final\\|inline\\|local\\|nomask\\|optional\\|private\\|"
|
||||
"protected\\|static\\|variant"))
|
||||
(c-lang-defconst c-specifier-kwds
|
||||
c '("auto" "const" "extern" "register" "static" "volatile")
|
||||
(c++ objc idl) (append '("friend" "inline" "virtual")
|
||||
(c-lang-var c-specifier-kwds c))
|
||||
;; Note: `const' is not used in Java, but it's still a reserved keyword.
|
||||
java '("abstract" "const" "final" "native" "private" "protected"
|
||||
"public" "static" "synchronized" "transient" "volatile")
|
||||
pike '("final" "inline" "local" "nomask" "optional" "private"
|
||||
"protected" "static" "variant"))
|
||||
|
||||
;; Class/struct declaration keywords.
|
||||
(defconst c-C-class-kwds "struct\\|union")
|
||||
(defconst c-C++-class-kwds (concat c-C-class-kwds "\\|class"))
|
||||
(defconst c-ObjC-class-kwds "interface\\|implementation")
|
||||
(defconst c-Java-class-kwds "class\\|interface")
|
||||
(defconst c-IDL-class-kwds
|
||||
(concat c-C++-class-kwds "\\|interface\\|valuetype"))
|
||||
(defconst c-Pike-class-kwds "class")
|
||||
(c-lang-defconst c-class-kwds
|
||||
c '("struct" "union")
|
||||
c++ '("class" "struct" "union")
|
||||
objc '("interface" "implementation")
|
||||
java '("class" "interface")
|
||||
idl '("interface" "valuetype" "class" "struct" "union")
|
||||
pike '("class"))
|
||||
|
||||
;; Keywords introducing other declaration-level blocks.
|
||||
(defconst c-C-extra-toplevel-kwds "extern")
|
||||
(defconst c-C++-extra-toplevel-kwds
|
||||
(concat c-C-extra-toplevel-kwds "\\|namespace"))
|
||||
;;(defconst c-ObjC-extra-toplevel-kwds nil)
|
||||
;;(defconst c-Java-extra-toplevel-kwds nil)
|
||||
(defconst c-IDL-extra-toplevel-kwds "module")
|
||||
;;(defconst c-Pike-extra-toplevel-kwds nil)
|
||||
;; Regexp matching the start of a class.
|
||||
(c-lang-defconst c-class-key
|
||||
all (c-make-keywords-re t (c-lang-var c-class-kwds)))
|
||||
(c-lang-defconst c-class-key ; ObjC needs some tuning of the regexp.
|
||||
objc (concat "@" (c-lang-var c-class-key)))
|
||||
(c-lang-defvar c-class-key (c-lang-var c-class-key))
|
||||
|
||||
;; Keywords introducing other declaration-level constructs.
|
||||
(defconst c-C-other-decl-kwds "enum\\|typedef")
|
||||
(defconst c-C++-other-decl-kwds (concat c-C-other-decl-kwds "\\|template"))
|
||||
;;(defconst c-ObjC-other-decl-kwds nil)
|
||||
(defconst c-Java-other-decl-kwds "import\\|package")
|
||||
;;(defconst c-IDL-other-decl-kwds nil)
|
||||
(defconst c-Pike-other-decl-kwds "import\\|inherit")
|
||||
;; Keywords introducing blocks besides classes that contain another
|
||||
;; declaration level.
|
||||
(c-lang-defconst c-other-decl-block-kwds
|
||||
c '("extern")
|
||||
c++ '("namespace" "extern")
|
||||
idl '("module"))
|
||||
|
||||
;; Keywords that occur in declaration-level constructs.
|
||||
;;(defconst c-C-decl-level-kwds nil)
|
||||
;;(defconst c-C++-decl-level-kwds nil)
|
||||
;;(defconst c-ObjC-decl-level-kwds nil)
|
||||
(defconst c-Java-decl-level-kwds "extends\\|implements\\|throws")
|
||||
;;(defconst c-IDL-decl-level-kwds nil)
|
||||
;;(defconst c-Pike-decl-level-kwds nil)
|
||||
;; Regexp matching the start of blocks besides classes that contain
|
||||
;; another declaration level.
|
||||
(c-lang-defconst c-other-decl-block-key
|
||||
all (c-make-keywords-re t (c-lang-var c-other-decl-block-kwds)))
|
||||
(c-lang-defvar c-other-decl-block-key (c-lang-var c-other-decl-block-key))
|
||||
|
||||
;; Keywords introducing declarations that can contain a block which
|
||||
;; might be followed by variable declarations, e.g. like "foo" in
|
||||
;; "class Foo { ... } foo;". So if there is a block in a declaration
|
||||
;; like that, it ends with the following ';' and not right away.
|
||||
(c-lang-defconst c-block-decls-with-vars
|
||||
c '("struct" "union" "enum" "typedef")
|
||||
c++ '("class" "struct" "union" "enum" "typedef"))
|
||||
|
||||
;; Regexp matching the `c-block-decls-with-vars' keywords, or nil in
|
||||
;; languages without such constructs.
|
||||
(c-lang-defconst c-opt-block-decls-with-vars-key
|
||||
all (and (c-lang-var c-block-decls-with-vars)
|
||||
(c-make-keywords-re t (c-lang-var c-block-decls-with-vars))))
|
||||
(c-lang-defvar c-opt-block-decls-with-vars-key
|
||||
(c-lang-var c-opt-block-decls-with-vars-key))
|
||||
|
||||
;; Keywords introducing declarations that has not been accounted for
|
||||
;; by any of the above.
|
||||
(c-lang-defconst c-other-decl-kwds
|
||||
;; FIXME: Shouldn't "template" be moved to c-specifier-kwds for C++?
|
||||
c++ '("template")
|
||||
java '("import" "package")
|
||||
pike '("import" "inherit"))
|
||||
|
||||
;; Keywords introducing extra declaration specifiers in the region
|
||||
;; between the header and the body (i.e. the "K&R-region") in
|
||||
;; declarations.
|
||||
(c-lang-defconst c-decl-spec-kwds java '("extends" "implements" "throws"))
|
||||
|
||||
;; Protection label keywords in classes.
|
||||
;;(defconst c-C-protection-kwds nil)
|
||||
(defconst c-C++-protection-kwds "private\\|protected\\|public")
|
||||
(defconst c-ObjC-protection-kwds c-C++-protection-kwds)
|
||||
;;(defconst c-Java-protection-kwds nil)
|
||||
;;(defconst c-IDL-protection-kwds nil)
|
||||
;;(defconst c-Pike-protection-kwds nil)
|
||||
(c-lang-defconst c-protection-kwds
|
||||
(c++ objc) '("private" "protected" "public"))
|
||||
|
||||
;; Statement keywords followed directly by a block.
|
||||
(defconst c-C-block-stmt-1-kwds "do\\|else")
|
||||
(defconst c-C++-block-stmt-1-kwds
|
||||
(concat c-C-block-stmt-1-kwds "\\|asm\\|try"))
|
||||
(defconst c-ObjC-block-stmt-1-kwds c-C++-block-stmt-1-kwds)
|
||||
(defconst c-Java-block-stmt-1-kwds
|
||||
(concat c-C-block-stmt-1-kwds "\\|finally\\|try"))
|
||||
;;(defconst c-IDL-block-stmt-1-kwds nil)
|
||||
(defconst c-Pike-block-stmt-1-kwds c-C-block-stmt-1-kwds)
|
||||
;; Statement keywords followed directly by a substatement.
|
||||
(c-lang-defconst c-block-stmt-1-kwds
|
||||
(c pike) '("do" "else")
|
||||
(c++ objc) '("do" "else" "asm" "try")
|
||||
java '("do" "else" "finally" "try"))
|
||||
|
||||
;; Statement keywords followed by a paren sexp and then by a block.
|
||||
(defconst c-C-block-stmt-2-kwds "for\\|if\\|switch\\|while")
|
||||
(defconst c-C++-block-stmt-2-kwds (concat c-C-block-stmt-2-kwds "\\|catch"))
|
||||
(defconst c-ObjC-block-stmt-2-kwds c-C++-block-stmt-2-kwds)
|
||||
(defconst c-Java-block-stmt-2-kwds
|
||||
(concat c-C++-block-stmt-2-kwds "\\|synchronized"))
|
||||
;;(defconst c-IDL-block-stmt-2-kwds nil)
|
||||
(defconst c-Pike-block-stmt-2-kwds c-C-block-stmt-2-kwds)
|
||||
;; Regexp matching the start of any statement followed directly by a
|
||||
;; substatement (doesn't match a bare block, however).
|
||||
(c-lang-defconst c-block-stmt-1-key
|
||||
all (c-make-keywords-re t (c-lang-var c-block-stmt-1-kwds)))
|
||||
(c-lang-defvar c-block-stmt-1-key (c-lang-var c-block-stmt-1-key))
|
||||
|
||||
;; Statement keywords followed by a paren sexp and then by a substatement.
|
||||
(c-lang-defconst c-block-stmt-2-kwds
|
||||
c '("for" "if" "switch" "while")
|
||||
(c++ objc) '("for" "if" "switch" "while" "catch")
|
||||
java '("for" "if" "switch" "while" "catch" "synchronized")
|
||||
pike '("for" "if" "switch" "while" "foreach"))
|
||||
|
||||
;; Regexp matching the start of any statement followed by a paren sexp
|
||||
;; and then by a substatement.
|
||||
(c-lang-defconst c-block-stmt-2-key
|
||||
all (c-make-keywords-re t (c-lang-var c-block-stmt-2-kwds)))
|
||||
(c-lang-defvar c-block-stmt-2-key (c-lang-var c-block-stmt-2-key))
|
||||
|
||||
;; Regexp matching the start of any statement that has a substatement
|
||||
;; (except a bare block). Nil in languages that doesn't have such
|
||||
;; constructs.
|
||||
(c-lang-defconst c-opt-block-stmt-key
|
||||
all (if (or (c-lang-var c-block-stmt-1-kwds)
|
||||
(c-lang-var c-block-stmt-2-kwds))
|
||||
(c-make-keywords-re t
|
||||
(c-lang-var c-block-stmt-1-kwds)
|
||||
(c-lang-var c-block-stmt-2-kwds))))
|
||||
(c-lang-defvar c-opt-block-stmt-key (c-lang-var c-opt-block-stmt-key))
|
||||
|
||||
;; Statement keywords followed by an expression or nothing.
|
||||
(defconst c-C-simple-stmt-kwds "break\\|continue\\|goto\\|return")
|
||||
(defconst c-C++-simple-stmt-kwds c-C-simple-stmt-kwds)
|
||||
(defconst c-ObjC-simple-stmt-kwds c-C-simple-stmt-kwds)
|
||||
(defconst c-Java-simple-stmt-kwds
|
||||
;; Note: `goto' is not a valid statement, but the keyword is still reserved.
|
||||
(concat c-C-simple-stmt-kwds "\\|throw"))
|
||||
;;(defconst c-IDL-simple-stmt-kwds nil)
|
||||
(defconst c-Pike-simple-stmt-kwds "break\\|continue\\|return")
|
||||
(c-lang-defconst c-simple-stmt-kwds
|
||||
(c c++ objc) '("break" "continue" "goto" "return")
|
||||
;; Note: `goto' is not valid in Java, but the keyword is still reserved.
|
||||
java '("break" "continue" "goto" "return" "throw")
|
||||
pike '("break" "continue" "return"))
|
||||
|
||||
;; Statement keywords followed by an assembler expression.
|
||||
(c-lang-defconst c-asm-stmt-kwds
|
||||
(c c++) '("asm" "__asm__"))
|
||||
|
||||
;; Regexp matching the start of an assembler statement. Nil in
|
||||
;; languages that doesn't support that.
|
||||
(c-lang-defconst c-opt-asm-stmt-key
|
||||
all (if (c-lang-var c-asm-stmt-kwds)
|
||||
(c-make-keywords-re t (c-lang-var c-asm-stmt-kwds))))
|
||||
(c-lang-defvar c-opt-asm-stmt-key (c-lang-var c-opt-asm-stmt-key))
|
||||
|
||||
;; Keywords introducing labels in blocks.
|
||||
(defconst c-C-label-kwds "case\\|default")
|
||||
(defconst c-C++-label-kwds c-C-label-kwds)
|
||||
(defconst c-ObjC-label-kwds c-C-label-kwds)
|
||||
(defconst c-Java-label-kwds c-C-label-kwds)
|
||||
;;(defconst c-IDL-label-kwds nil)
|
||||
(defconst c-Pike-label-kwds c-C-label-kwds)
|
||||
(c-lang-defconst c-label-kwds (c c++ objc java pike) '("case" "default"))
|
||||
|
||||
;; Regexp matching any keyword that introduces a label.
|
||||
(c-lang-defconst c-label-kwds-regexp
|
||||
all (c-make-keywords-re t (c-lang-var c-label-kwds)))
|
||||
(c-lang-defvar c-label-kwds-regexp (c-lang-var c-label-kwds-regexp))
|
||||
|
||||
;; Keywords that can occur anywhere in expressions.
|
||||
(defconst c-C-expr-kwds "sizeof")
|
||||
(defconst c-C++-expr-kwds
|
||||
(concat c-C-expr-kwds "\\|delete\\|new\\|operator\\|this\\|throw"))
|
||||
(defconst c-ObjC-expr-kwds c-C-expr-kwds)
|
||||
(defconst c-Java-expr-kwds "instanceof\\|new\\|super\\|this")
|
||||
;;(defconst c-IDL-expr-kwds nil)
|
||||
(defconst c-Pike-expr-kwds
|
||||
(concat c-C-expr-kwds "\\|catch\\|class\\|gauge\\|lambda\\|predef"))
|
||||
(c-lang-defconst c-expr-kwds
|
||||
(c objc) '("sizeof")
|
||||
c++ '("sizeof" "delete" "new" "operator" "this" "throw")
|
||||
java '("instanceof" "new" "super" "this")
|
||||
pike '("sizeof" "catch" "class" "gauge" "lambda" "predef"))
|
||||
|
||||
;; All keywords.
|
||||
(defconst c-C-keywords
|
||||
(concat c-C-primitive-type-kwds "\\|" c-C-specifier-kwds
|
||||
"\\|" c-C-class-kwds "\\|" c-C-extra-toplevel-kwds
|
||||
"\\|" c-C-other-decl-kwds
|
||||
;; "\\|" c-C-decl-level-kwds "\\|" c-C-protection-kwds
|
||||
"\\|" c-C-block-stmt-1-kwds "\\|" c-C-block-stmt-2-kwds
|
||||
"\\|" c-C-simple-stmt-kwds "\\|" c-C-label-kwds
|
||||
"\\|" c-C-expr-kwds))
|
||||
(defconst c-C++-keywords
|
||||
(concat c-C++-primitive-type-kwds "\\|" c-C++-specifier-kwds
|
||||
"\\|" c-C++-class-kwds "\\|" c-C++-extra-toplevel-kwds
|
||||
"\\|" c-C++-other-decl-kwds
|
||||
;; "\\|" c-C++-decl-level-kwds
|
||||
"\\|" c-C++-protection-kwds
|
||||
"\\|" c-C++-block-stmt-1-kwds "\\|" c-C++-block-stmt-2-kwds
|
||||
"\\|" c-C++-simple-stmt-kwds "\\|" c-C++-label-kwds
|
||||
"\\|" c-C++-expr-kwds))
|
||||
(defconst c-ObjC-keywords
|
||||
(concat c-ObjC-primitive-type-kwds "\\|" c-ObjC-specifier-kwds
|
||||
"\\|" c-ObjC-class-kwds
|
||||
;; "\\|" c-ObjC-extra-toplevel-kwds
|
||||
;; "\\|" c-ObjC-other-decl-kwds "\\|" c-ObjC-decl-level-kwds
|
||||
"\\|" c-ObjC-protection-kwds
|
||||
"\\|" c-ObjC-block-stmt-1-kwds "\\|" c-ObjC-block-stmt-2-kwds
|
||||
"\\|" c-ObjC-simple-stmt-kwds "\\|" c-ObjC-label-kwds
|
||||
"\\|" c-ObjC-expr-kwds))
|
||||
(defconst c-Java-keywords
|
||||
(concat c-Java-primitive-type-kwds "\\|" c-Java-specifier-kwds
|
||||
"\\|" c-Java-class-kwds
|
||||
;; "\\|" c-Java-extra-toplevel-kwds
|
||||
"\\|" c-Java-other-decl-kwds "\\|" c-Java-decl-level-kwds
|
||||
;; "\\|" c-Java-protection-kwds
|
||||
"\\|" c-Java-block-stmt-1-kwds "\\|" c-Java-block-stmt-2-kwds
|
||||
"\\|" c-Java-simple-stmt-kwds "\\|" c-Java-label-kwds
|
||||
"\\|" c-Java-expr-kwds))
|
||||
(defconst c-IDL-keywords
|
||||
(concat c-IDL-primitive-type-kwds "\\|" c-IDL-specifier-kwds
|
||||
"\\|" c-IDL-class-kwds "\\|" c-IDL-extra-toplevel-kwds
|
||||
;; "\\|" c-IDL-other-decl-kwds "\\|" c-IDL-decl-level-kwds
|
||||
;; "\\|" c-IDL-protection-kwds
|
||||
;; "\\|" c-IDL-block-stmt-1-kwds "\\|" c-IDL-block-stmt-2-kwds
|
||||
;; "\\|" c-IDL-simple-stmt-kwds "\\|" c-IDL-label-kwds
|
||||
;; "\\|" c-IDL-expr-kwds)
|
||||
))
|
||||
(defconst c-Pike-keywords
|
||||
(concat c-Pike-primitive-type-kwds "\\|" c-Pike-specifier-kwds
|
||||
"\\|" c-Pike-class-kwds
|
||||
;; "\\|" c-Pike-extra-toplevel-kwds
|
||||
"\\|" c-Pike-other-decl-kwds
|
||||
;; "\\|" c-Pike-decl-level-kwds "\\|" c-Pike-protection-kwds
|
||||
"\\|" c-Pike-block-stmt-1-kwds "\\|" c-Pike-block-stmt-2-kwds
|
||||
"\\|" c-Pike-simple-stmt-kwds "\\|" c-Pike-label-kwds
|
||||
"\\|" c-Pike-expr-kwds))
|
||||
;; Keywords that start lambda constructs, i.e. function definitions in
|
||||
;; expressions.
|
||||
(c-lang-defconst c-lambda-kwds pike '("lambda"))
|
||||
|
||||
(defvar c-keywords nil)
|
||||
(make-variable-buffer-local 'c-keywords)
|
||||
;; Regexp matching the start of lambda constructs, or nil in languages
|
||||
;; that doesn't have such things.
|
||||
(c-lang-defconst c-opt-lambda-key
|
||||
pike (c-make-keywords-re t (c-lang-var c-lambda-kwds)))
|
||||
(c-lang-defvar c-opt-lambda-key (c-lang-var c-opt-lambda-key))
|
||||
|
||||
;; Keywords defining protection levels
|
||||
(defconst c-protection-key "\\<\\(public\\|protected\\|private\\)\\>")
|
||||
;; Keywords that start constructs followed by statement blocks which
|
||||
;; can be used in expressions (the gcc extension for this in C and C++
|
||||
;; is handled separately).
|
||||
(c-lang-defconst c-inexpr-block-kwds pike '("catch" "gauge"))
|
||||
|
||||
;; Regexps introducing class definitions.
|
||||
(defconst c-C-class-key (c-paren-re c-C-class-kwds))
|
||||
(defconst c-C++-class-key (c-paren-re c-C++-class-kwds))
|
||||
(defconst c-IDL-class-key (c-paren-re c-IDL-class-kwds))
|
||||
(defconst c-ObjC-class-key
|
||||
(concat
|
||||
"@\\(" c-ObjC-class-kwds "\\)\\s +"
|
||||
c-symbol-key ;name of the class
|
||||
"\\(\\s *:\\s *" c-symbol-key "\\)?" ;maybe followed by the superclass
|
||||
"\\(\\s *<[^>]+>\\)?" ;and maybe the adopted protocols list
|
||||
))
|
||||
(defconst c-Java-class-key
|
||||
(concat
|
||||
"\\(" c-protection-key "\\s +\\)?"
|
||||
"\\(" c-Java-class-kwds "\\)\\s +"
|
||||
c-symbol-key ;name of the class
|
||||
"\\(\\s *extends\\s *" c-symbol-key "\\)?" ;maybe followed by superclass
|
||||
;;"\\(\\s *implements *[^{]+{\\)?" ;maybe the adopted protocols list
|
||||
))
|
||||
(defconst c-Pike-class-key (c-paren-re c-Pike-class-kwds))
|
||||
;; Regexp matching the start of in-expression statements, or nil in
|
||||
;; languages that doesn't have such things.
|
||||
(c-lang-defconst c-opt-inexpr-block-key
|
||||
pike (c-make-keywords-re t (c-lang-var c-inexpr-block-kwds)))
|
||||
(c-lang-defvar c-opt-inexpr-block-key (c-lang-var c-opt-inexpr-block-key))
|
||||
|
||||
(defvar c-class-key c-C-class-key)
|
||||
(make-variable-buffer-local 'c-class-key)
|
||||
;; Keywords that start classes in expressions.
|
||||
(c-lang-defconst c-inexpr-class-kwds
|
||||
java '("new")
|
||||
pike '("class"))
|
||||
|
||||
(defconst c-C-extra-toplevel-key (c-paren-re c-C-extra-toplevel-kwds))
|
||||
(defconst c-C++-extra-toplevel-key (c-paren-re c-C++-extra-toplevel-kwds))
|
||||
(defconst c-IDL-extra-toplevel-key (c-paren-re c-IDL-extra-toplevel-kwds))
|
||||
;; Regexp matching the start of a class in an expression, or nil in
|
||||
;; languages that doesn't have such things.
|
||||
(c-lang-defconst c-opt-inexpr-class-key
|
||||
(java pike) (c-make-keywords-re t (c-lang-var c-inexpr-class-kwds)))
|
||||
(c-lang-defvar c-opt-inexpr-class-key (c-lang-var c-opt-inexpr-class-key))
|
||||
|
||||
(defvar c-extra-toplevel-key c-C-extra-toplevel-key)
|
||||
(make-variable-buffer-local 'c-extra-toplevel-key)
|
||||
;; Regexp matching the start of any class, both at top level and in
|
||||
;; expressions.
|
||||
(c-lang-defconst c-any-class-key
|
||||
all (c-make-keywords-re t
|
||||
(c-lang-var c-class-kwds)
|
||||
(c-lang-var c-inexpr-class-kwds)))
|
||||
(c-lang-defconst c-any-class-key ; ObjC needs some tuning of the regexp.
|
||||
objc (concat "@" (c-lang-var c-any-class-key)))
|
||||
(c-lang-defvar c-any-class-key (c-lang-var c-any-class-key))
|
||||
|
||||
;; Keywords that can introduce bitfields in the languages that supports that.
|
||||
(defconst c-C-bitfield-key "\\(char\\|int\\|long\\|signed\\|unsigned\\)")
|
||||
;; Regexp matching the start of any declaration-level block that
|
||||
;; contain another declaration level, i.e. that isn't a function
|
||||
;; block.
|
||||
(c-lang-defconst c-decl-block-key
|
||||
all (c-make-keywords-re t
|
||||
(c-lang-var c-class-kwds)
|
||||
(c-lang-var c-other-decl-block-kwds)
|
||||
(c-lang-var c-inexpr-class-kwds)))
|
||||
(c-lang-defconst c-decl-block-key ; ObjC needs some tuning of the regexp.
|
||||
objc (concat "@" (c-lang-var c-decl-block-key)))
|
||||
(c-lang-defvar c-decl-block-key (c-lang-var c-decl-block-key))
|
||||
|
||||
(defvar c-bitfield-key nil)
|
||||
(make-variable-buffer-local 'c-bitfield-key)
|
||||
;; Keywords that can introduce bitfields.
|
||||
(c-lang-defconst c-bitfield-kwds
|
||||
(c c++) '("char" "int" "long" "signed" "unsigned"))
|
||||
|
||||
;; regexp describing access protection clauses. language specific
|
||||
(defvar c-access-key nil)
|
||||
(make-variable-buffer-local 'c-access-key)
|
||||
(defconst c-C++-access-key
|
||||
(concat "\\<\\(" c-C++-protection-kwds "\\)\\>[ \t]*:"))
|
||||
;;(defconst c-IDL-access-key nil)
|
||||
(defconst c-ObjC-access-key (concat "@" c-protection-key))
|
||||
;;(defconst c-Java-access-key nil)
|
||||
;;(defconst c-Pike-access-key nil)
|
||||
;; Regexp matching the start of a bitfield (not uniquely), or nil in
|
||||
;; languages without bitfield support.
|
||||
(c-lang-defconst c-opt-bitfield-key
|
||||
(c c++) (c-make-keywords-re t (c-lang-var c-bitfield-kwds)))
|
||||
(c-lang-defvar c-opt-bitfield-key (c-lang-var c-opt-bitfield-key))
|
||||
|
||||
;; keywords introducing conditional blocks
|
||||
(defconst c-C-conditional-key nil)
|
||||
(defconst c-C++-conditional-key nil)
|
||||
(defconst c-IDL-conditional-key nil)
|
||||
(defconst c-ObjC-conditional-key nil)
|
||||
(defconst c-Java-conditional-key nil)
|
||||
(defconst c-Pike-conditional-key nil)
|
||||
;; All keywords as a list.
|
||||
(c-lang-defconst c-keywords
|
||||
all (delete-duplicates (append (c-lang-var c-primitive-type-kwds)
|
||||
(c-lang-var c-specifier-kwds)
|
||||
(c-lang-var c-class-kwds)
|
||||
(c-lang-var c-other-decl-block-kwds)
|
||||
(c-lang-var c-block-decls-with-vars)
|
||||
(c-lang-var c-other-decl-kwds)
|
||||
(c-lang-var c-decl-spec-kwds)
|
||||
(c-lang-var c-protection-kwds)
|
||||
(c-lang-var c-block-stmt-1-kwds)
|
||||
(c-lang-var c-block-stmt-2-kwds)
|
||||
(c-lang-var c-simple-stmt-kwds)
|
||||
(c-lang-var c-asm-stmt-kwds)
|
||||
(c-lang-var c-label-kwds)
|
||||
(c-lang-var c-expr-kwds)
|
||||
(c-lang-var c-lambda-kwds)
|
||||
(c-lang-var c-inexpr-block-kwds)
|
||||
(c-lang-var c-inexpr-class-kwds)
|
||||
(c-lang-var c-bitfield-kwds)
|
||||
nil)
|
||||
:test 'string-equal))
|
||||
(c-lang-defvar c-keywords (c-lang-var c-keywords))
|
||||
|
||||
(let ((all-kws "for\\|if\\|do\\|else\\|while\\|switch")
|
||||
(exc-kws "\\|try\\|catch")
|
||||
(thr-kws "\\|finally\\|synchronized")
|
||||
(front "\\<\\(")
|
||||
(back "\\)\\>[^_]"))
|
||||
(setq c-C-conditional-key (concat front all-kws back)
|
||||
c-C++-conditional-key (concat front all-kws exc-kws back)
|
||||
;; c-IDL-conditional-key is nil.
|
||||
c-ObjC-conditional-key c-C-conditional-key
|
||||
c-Java-conditional-key (concat front all-kws exc-kws thr-kws back)
|
||||
c-Pike-conditional-key (concat front all-kws "\\|foreach" back)))
|
||||
;; All keywords as an adorned regexp.
|
||||
(c-lang-defconst c-keywords-regexp
|
||||
all (c-make-keywords-re t (c-lang-var c-keywords)))
|
||||
(c-lang-defvar c-keywords-regexp (c-lang-var c-keywords-regexp))
|
||||
|
||||
(defvar c-conditional-key c-C-conditional-key)
|
||||
(make-variable-buffer-local 'c-conditional-key)
|
||||
;; Regexp matching an access protection label in a class, or nil in
|
||||
;; languages that doesn't have such things.
|
||||
(c-lang-defconst c-opt-access-key
|
||||
c++ (concat "\\("
|
||||
(c-make-keywords-re nil (c-lang-var c-protection-kwds))
|
||||
"\\)[ \t\n\r]*:"))
|
||||
(c-lang-defconst c-opt-access-key
|
||||
objc (concat "@" (c-make-keywords-re t (c-lang-var c-protection-kwds))))
|
||||
(c-lang-defvar c-opt-access-key (c-lang-var c-opt-access-key))
|
||||
|
||||
;; keywords describing method definition introductions
|
||||
(defvar c-method-key nil)
|
||||
(make-variable-buffer-local 'c-method-key)
|
||||
;; Regexp matching a normal label, i.e. not a label that's recognized
|
||||
;; with a keyword, like switch labels. It's only used at the
|
||||
;; beginning of a statement.
|
||||
(c-lang-defconst c-label-key
|
||||
all (concat (c-lang-var c-symbol-key) "[ \t\n\r]*:\\([^:]\\|$\\)"))
|
||||
(c-lang-defvar c-label-key (c-lang-var c-label-key))
|
||||
|
||||
(defconst c-ObjC-method-key
|
||||
(concat
|
||||
"^\\s *[+-]\\s *"
|
||||
"\\(([^)]*)\\)?" ; return type
|
||||
;; \\s- in objc syntax table does not include \n
|
||||
;; since it is considered the end of //-comments.
|
||||
"[ \t\n]*" c-symbol-key))
|
||||
;; Regexp matching the beginning of a declaration specifier in the
|
||||
;; region between the header and the body of a declaration.
|
||||
;;
|
||||
;; FIXME: This is currently not used in a uniformly; c++-mode and
|
||||
;; java-mode each have their own ways of using it.
|
||||
(c-lang-defconst c-opt-decl-spec-key
|
||||
c++ (concat ":?[ \t\n\r]*\\(virtual[ \t\n\r]+\\)?\\("
|
||||
(c-make-keywords-re nil (c-lang-var c-protection-kwds))
|
||||
"\\)[ \t\n\r]+"
|
||||
(c-lang-var c-symbol-key))
|
||||
java (c-make-keywords-re t (c-lang-var c-decl-spec-kwds)))
|
||||
(c-lang-defvar c-opt-decl-spec-key (c-lang-var c-opt-decl-spec-key))
|
||||
|
||||
;; comment starter definitions for various languages. language specific
|
||||
(defconst c-C++-comment-start-regexp "/[/*]")
|
||||
(defconst c-C-comment-start-regexp c-C++-comment-start-regexp)
|
||||
(defconst c-IDL-comment-start-regexp c-C++-comment-start-regexp)
|
||||
(defconst c-ObjC-comment-start-regexp c-C++-comment-start-regexp)
|
||||
(defconst c-Pike-comment-start-regexp c-C++-comment-start-regexp)
|
||||
;; We need to match all 3 Java style comments
|
||||
;; 1) Traditional C block; 2) javadoc /** ...; 3) C++ style
|
||||
(defconst c-Java-comment-start-regexp "/\\(/\\|[*][*]?\\)")
|
||||
(defvar c-comment-start-regexp c-C++-comment-start-regexp)
|
||||
(make-variable-buffer-local 'c-comment-start-regexp)
|
||||
;; Regexp describing friend declarations classes, or nil in languages
|
||||
;; that doesn't have such things.
|
||||
(c-lang-defconst c-opt-friend-key
|
||||
;; FIXME: Ought to use c-specifier-kwds or similar, and the template
|
||||
;; skipping isn't done properly.
|
||||
c++ "friend[ \t]+\\|template[ \t]*<.+>[ \t]*friend[ \t]+")
|
||||
(c-lang-defvar c-opt-friend-key (c-lang-var c-opt-friend-key))
|
||||
|
||||
;; Regexp describing a switch's case or default label for all languages
|
||||
(defconst c-switch-label-key "\\(\\(case[( \t]+\\S .*\\)\\|default[ \t]*\\):")
|
||||
;; Regexp describing any label.
|
||||
(defconst c-label-key (concat c-symbol-key ":\\([^:]\\|$\\)"))
|
||||
;; Special regexp to match the start of methods.
|
||||
(c-lang-defconst c-opt-method-key
|
||||
objc (concat
|
||||
"^\\s *[+-]\\s *"
|
||||
"\\(([^)]*)\\)?" ; return type
|
||||
;; \\s- in objc syntax table does not include \n
|
||||
;; since it is considered the end of //-comments.
|
||||
"[ \t\n]*" (c-lang-var c-symbol-key)))
|
||||
(c-lang-defvar c-opt-method-key (c-lang-var c-opt-method-key))
|
||||
|
||||
;; Regexp describing class inheritance declarations. TBD: this should
|
||||
;; be language specific, and only makes sense for C++
|
||||
(defconst c-inher-key
|
||||
(concat "\\(\\<static\\>\\s +\\)?"
|
||||
c-C++-class-key "[ \t]+" c-symbol-key
|
||||
"\\([ \t]*:[ \t]*\\)\\s *[^;]"))
|
||||
|
||||
;; Regexp describing C++ base classes in a derived class definition.
|
||||
;; TBD: this should be language specific, and only makes sense for C++
|
||||
(defvar c-baseclass-key
|
||||
(concat
|
||||
":?[ \t]*\\(virtual[ \t]+\\)?\\("
|
||||
c-protection-key "[ \t]+\\)" c-symbol-key))
|
||||
(make-variable-buffer-local 'c-baseclass-key)
|
||||
|
||||
;; Regexp describing friend declarations in C++ classes.
|
||||
(defconst c-C++-friend-key
|
||||
"friend[ \t]+\\|template[ \t]*<.+>[ \t]*friend[ \t]+")
|
||||
|
||||
;; Regexp describing Java inheritance and throws clauses.
|
||||
(defconst c-Java-special-key "\\(implements\\|extends\\|throws\\)[^_]")
|
||||
|
||||
;; Regexp describing the beginning of a Java top-level definition.
|
||||
(defconst c-Java-defun-prompt-regexp
|
||||
"^[ \t]*\\(\\(\\(public\\|protected\\|private\\|const\\|abstract\\|synchronized\\|final\\|static\\|threadsafe\\|transient\\|native\\|volatile\\)\\s-+\\)*\\(\\(\\([[a-zA-Z][][_$.a-zA-Z0-9]*[][_$.a-zA-Z0-9]+\\|[[a-zA-Z]\\)\\s-*\\)\\s-+\\)\\)?\\(\\([[a-zA-Z][][_$.a-zA-Z0-9]*\\s-+\\)\\s-*\\)?\\([_a-zA-Z][^][ \t:;.,{}()=]*\\|\\([_$a-zA-Z][_$.a-zA-Z0-9]*\\)\\)\\s-*\\(([^);{}]*)\\)?\\([] \t]*\\)\\(\\s-*\\<throws\\>\\s-*\\(\\([_$a-zA-Z][_$.a-zA-Z0-9]*\\)[, \t\n\r\f]*\\)+\\)?\\s-*")
|
||||
|
||||
;; Regexp to append to paragraph-start.
|
||||
(defvar c-append-paragraph-start "$")
|
||||
(make-variable-buffer-local 'c-append-paragraph-start)
|
||||
(defconst c-Java-javadoc-paragraph-start
|
||||
"\\(@[a-zA-Z]+\\>\\|$\\)")
|
||||
(defconst c-Pike-pikedoc-paragraph-start
|
||||
"\\(@[a-zA-Z]+\\>\\([^{]\\|$\\)\\|$\\)")
|
||||
|
||||
;; Regexp to append to paragraph-separate.
|
||||
(defvar c-append-paragraph-separate "$")
|
||||
(make-variable-buffer-local 'c-append-paragraph-separate)
|
||||
(defconst c-Pike-pikedoc-paragraph-separate c-Pike-pikedoc-paragraph-start)
|
||||
|
||||
;; Regexp that starts lambda constructs.
|
||||
(defvar c-lambda-key nil)
|
||||
(make-variable-buffer-local 'c-lambda-key)
|
||||
(defconst c-Pike-lambda-key "\\<lambda\\>")
|
||||
|
||||
;; Regexp that are followed by a statement block in expressions.
|
||||
(defvar c-inexpr-block-key nil)
|
||||
(make-variable-buffer-local 'c-inexpr-block-key)
|
||||
(defconst c-Pike-inexpr-block-key "\\<\\(catch\\|gauge\\)\\>")
|
||||
|
||||
;; Regexp that may be followed by an anonymous class in expressions.
|
||||
(defvar c-inexpr-class-key nil)
|
||||
(make-variable-buffer-local 'c-inexpr-class-key)
|
||||
(defconst c-Java-inexpr-class-key "\\<new\\>")
|
||||
(defconst c-Pike-inexpr-class-key "\\<class\\>")
|
||||
;; Name of functions in cpp expressions that take an identifier as the
|
||||
;; argument.
|
||||
(c-lang-defconst c-cpp-defined-fns
|
||||
(c c++) '("defined")
|
||||
pike '("defined" "efun" "constant"))
|
||||
|
||||
;; List of open- and close-chars that makes up a pike-style brace
|
||||
;; list, ie for a `([ ])' list there should be a cons (?\[ . ?\]) in
|
||||
;; list, i.e. for a `([ ])' list there should be a cons (?\[ . ?\]) in
|
||||
;; this list.
|
||||
(defvar c-special-brace-lists nil)
|
||||
(make-variable-buffer-local 'c-special-brace-lists)
|
||||
(defconst c-Pike-special-brace-lists '((?{ . ?})
|
||||
(?\[ . ?\])
|
||||
(?< . ?>)))
|
||||
(c-lang-defconst c-special-brace-lists pike '((?{ . ?})
|
||||
(?\[ . ?\])
|
||||
(?< . ?>)))
|
||||
(c-lang-defvar c-special-brace-lists (c-lang-var c-special-brace-lists))
|
||||
|
||||
;; Non-nil means K&R style argument declarations are valid.
|
||||
(c-lang-defconst c-recognize-knr-p c t)
|
||||
(c-lang-defvar c-recognize-knr-p (c-lang-var c-recognize-knr-p))
|
||||
|
||||
;; Regexp to match the start of any type of comment.
|
||||
;;
|
||||
;; FIXME: Ought to use c-comment-prefix-regexp with some modifications
|
||||
;; instead of this.
|
||||
(c-lang-defconst c-comment-start-regexp
|
||||
(c c++ objc idl pike) "/[/*]"
|
||||
;; We need to match all 3 Java style comments
|
||||
;; 1) Traditional C block; 2) javadoc /** ...; 3) C++ style
|
||||
java "/\\(/\\|[*][*]?\\)")
|
||||
(c-lang-defvar c-comment-start-regexp (c-lang-var c-comment-start-regexp))
|
||||
|
||||
;; Strings that starts and ends comments inserted with M-; etc.
|
||||
;; comment-start and comment-end are initialized from these.
|
||||
(c-lang-defconst comment-start
|
||||
c "/* "
|
||||
(c++ objc java idl pike) "// ")
|
||||
(c-lang-defvar comment-start (c-lang-var comment-start))
|
||||
(c-lang-defconst comment-end
|
||||
c "*/"
|
||||
(c++ objc java idl pike) "")
|
||||
(c-lang-defvar comment-end (c-lang-var comment-end))
|
||||
|
||||
;; Regexp that matches when there is no syntactically significant text
|
||||
;; before eol. Macros are regarded as syntactically significant text
|
||||
;; here.
|
||||
(c-lang-defvar c-syntactic-eol
|
||||
(concat (concat
|
||||
;; Match horizontal whitespace and block comments that
|
||||
;; doesn't contain newlines.
|
||||
"\\(\\s \\|"
|
||||
(concat "/\\*"
|
||||
"\\([^*\n\r]\\|\\*[^/\n\r]\\)*"
|
||||
"\\*/")
|
||||
"\\)*")
|
||||
(concat
|
||||
;; Match eol (possibly inside a block comment), or the
|
||||
;; beginning of a line comment. Note: This has to be
|
||||
;; modified for awk where line comments start with '#'.
|
||||
"\\("
|
||||
(concat "\\("
|
||||
"/\\*\\([^*\n\r]\\|\\*[^/\n\r]\\)*"
|
||||
"\\)?"
|
||||
"$")
|
||||
"\\|//\\)")))
|
||||
|
||||
;; Regexp to append to paragraph-start.
|
||||
(c-lang-defconst paragraph-start
|
||||
(c c++ objc idl) "$"
|
||||
java "\\(@[a-zA-Z]+\\>\\|$\\)" ; For Javadoc.
|
||||
pike "\\(@[a-zA-Z]+\\>\\([^{]\\|$\\)\\|$\\)") ; For Pike refdoc.
|
||||
|
||||
;; Regexp to append to paragraph-separate.
|
||||
(c-lang-defconst paragraph-separate
|
||||
(c c++ objc java idl) "$"
|
||||
pike (c-lang-var paragraph-start))
|
||||
|
||||
;; Prefix added to `c-current-comment-prefix' to set
|
||||
;; `c-opt-in-comment-lc', or nil if it should be nil.
|
||||
(c-lang-defconst c-in-comment-lc-prefix pike "@[\n\r]\\s *")
|
||||
|
||||
;; Regexp to match in-comment line continuations, or nil in languages
|
||||
;; where that isn't applicable. It's assumed that it only might match
|
||||
;; from and including the last character on a line. Built from
|
||||
;; *-in-comment-lc-prefix and the current value of
|
||||
;; c-current-comment-prefix.
|
||||
(c-lang-defvar c-opt-in-comment-lc
|
||||
(if (c-lang-var c-in-comment-lc-prefix)
|
||||
(concat (c-lang-var c-in-comment-lc-prefix)
|
||||
c-current-comment-prefix)))
|
||||
|
||||
(defconst c-init-lang-defvars
|
||||
;; Make a lambda of the collected `c-lang-defvar' initializations.
|
||||
(cc-eval-when-compile
|
||||
(if (cc-bytecomp-is-compiling)
|
||||
(byte-compile-lambda `(lambda () ,c-lang-defvar-init-form))
|
||||
`(lambda () ,c-lang-defvar-init-form))))
|
||||
|
||||
(defun c-init-language-vars ()
|
||||
;; Initialize all `c-lang-defvar' variables according to
|
||||
;; `c-buffer-is-cc-mode'.
|
||||
(if (not (memq c-buffer-is-cc-mode
|
||||
'(c-mode c++-mode objc-mode java-mode idl-mode pike-mode)))
|
||||
(error "Cannot initialize language variables for unknown mode %s"
|
||||
c-buffer-is-cc-mode))
|
||||
(funcall c-init-lang-defvars))
|
||||
|
||||
;; Regexp trying to describe the beginning of a Java top-level
|
||||
;; definition. This is not used by CC Mode, nor is it maintained
|
||||
;; since it's practically impossible to write a regexp that reliably
|
||||
;; matches such a construct. Other tools are necessary.
|
||||
(defconst c-Java-defun-prompt-regexp
|
||||
"^[ \t]*\\(\\(\\(public\\|protected\\|private\\|const\\|abstract\\|synchronized\\|final\\|static\\|threadsafe\\|transient\\|native\\|volatile\\)\\s-+\\)*\\(\\(\\([[a-zA-Z][][_$.a-zA-Z0-9]*[][_$.a-zA-Z0-9]+\\|[[a-zA-Z]\\)\\s-*\\)\\s-+\\)\\)?\\(\\([[a-zA-Z][][_$.a-zA-Z0-9]*\\s-+\\)\\s-*\\)?\\([_a-zA-Z][^][ \t:;.,{}()=]*\\|\\([_$a-zA-Z][_$.a-zA-Z0-9]*\\)\\)\\s-*\\(([^);{}]*)\\)?\\([] \t]*\\)\\(\\s-*\\<throws\\>\\s-*\\(\\([_$a-zA-Z][_$.a-zA-Z0-9]*\\)[, \t\n\r\f]*\\)+\\)?\\s-*")
|
||||
|
||||
|
||||
;; Syntax tables.
|
||||
|
||||
(defun c-populate-syntax-table (table)
|
||||
;; Populate the syntax TABLE
|
||||
;; DO NOT TRY TO SET _ (UNDERSCORE) TO WORD CLASS!
|
||||
(modify-syntax-entry ?_ "_" table)
|
||||
(modify-syntax-entry ?\\ "\\" table)
|
||||
(modify-syntax-entry ?+ "." table)
|
||||
|
|
@ -466,15 +667,7 @@ Otherwise, this variable is nil. I.e. this variable is non-nil for
|
|||
(if c++-mode-syntax-table
|
||||
()
|
||||
(setq c++-mode-syntax-table (make-syntax-table))
|
||||
(c-populate-syntax-table c++-mode-syntax-table)
|
||||
;; TBD: does it make sense for colon to be symbol class in C++?
|
||||
;; I'm not so sure, since c-label-key is busted on lines like:
|
||||
;; Foo::bar( i );
|
||||
;; maybe c-label-key should be fixed instead of commenting this out,
|
||||
;; but it also bothers me that this only seems appropriate for C++
|
||||
;; and not C.
|
||||
;;(modify-syntax-entry ?: "_" c++-mode-syntax-table)
|
||||
)
|
||||
(c-populate-syntax-table c++-mode-syntax-table))
|
||||
|
||||
(defvar c++-template-syntax-table nil
|
||||
"A variant of `c++-mode-syntax-table' that defines `<' and `>' as
|
||||
|
|
@ -537,10 +730,6 @@ are parsed.")
|
|||
(defvar c-auto-hungry-string nil)
|
||||
(make-variable-buffer-local 'c-auto-hungry-string)
|
||||
|
||||
;; Non-nil means K&R style argument declarations are valid.
|
||||
(defvar c-recognize-knr-p t)
|
||||
(make-variable-buffer-local 'c-recognize-knr-p)
|
||||
|
||||
|
||||
(cc-provide 'cc-langs)
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program; see the file COPYING. If not, write to
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to
|
||||
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
|
|
@ -110,9 +110,9 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
|
|||
"[^()]*" ; no parentheses before
|
||||
"[^a-zA-Z0-9_:<>~]" ; match any non-identifier char
|
||||
"\\([a-zA-Z_][a-zA-Z0-9_:<>~]*\\)" ; match function name
|
||||
"[ \t]*(" ; see above, BUT
|
||||
"[ \t]*\\([^ \t(*][^)]*\\)?)" ; the arg list must not start
|
||||
"[ \t]*[^ \t;(]" ; with an asterisk or parentheses
|
||||
"\\([ \t\n]\\|\\\\\n\\)*(" ; see above, BUT the arg list
|
||||
"\\([ \t\n]\\|\\\\\n\\)*\\([^ \t\n(*][^)]*\\)?)" ; must not start
|
||||
"\\([ \t\n]\\|\\\\\n\\)*[^ \t\n;(]" ; with an asterisk or parentheses
|
||||
) 1)
|
||||
;; Special case for definitions using phony prototype macros like:
|
||||
;; `int main _PROTO( (int argc,char *argv[]) )'.
|
||||
|
|
@ -139,7 +139,7 @@ A sample value might look like: `\\(_P\\|_PROTO\\)'.")
|
|||
"[a-zA-Z0-9_]+" ; class name
|
||||
"\\(<[^>]+>\\)?" ; possibly explicitly specialized
|
||||
"\\)"
|
||||
"[ \t\n]*[:{]"
|
||||
"\\([ \t\n]\\|\\\\\n\\)*[:{]"
|
||||
) 3))
|
||||
"Imenu generic expression for C++ mode. See `imenu-generic-expression'.")
|
||||
|
||||
|
|
|
|||
|
|
@ -24,11 +24,11 @@
|
|||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program; see the file COPYING. If not, write to
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to
|
||||
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
(defconst c-version "5.28"
|
||||
(defconst c-version "5.29"
|
||||
"CC Mode version number.")
|
||||
|
||||
;; NOTE: Read the commentary below for the right way to submit bug reports!
|
||||
|
|
@ -115,8 +115,14 @@
|
|||
;; use:
|
||||
;;
|
||||
;; (require 'cc-mode)
|
||||
;;
|
||||
;; And in the major mode function:
|
||||
;;
|
||||
;; (c-initialize-cc-mode)
|
||||
|
||||
(defun c-leave-cc-mode-mode ()
|
||||
(setq c-buffer-is-cc-mode nil))
|
||||
|
||||
;;;###autoload
|
||||
(defun c-initialize-cc-mode ()
|
||||
(setq c-buffer-is-cc-mode t)
|
||||
|
|
@ -131,6 +137,7 @@
|
|||
;; Fix obsolete variables.
|
||||
(if (boundp 'c-comment-continuation-stars)
|
||||
(setq c-block-comment-prefix c-comment-continuation-stars))
|
||||
(add-hook 'change-major-mode-hook 'c-leave-cc-mode-mode)
|
||||
(setq c-initialization-ok t))
|
||||
;; Will try initialization hooks again if they failed.
|
||||
(put 'c-initialize-cc-mode initprop c-initialization-ok)))
|
||||
|
|
@ -154,6 +161,19 @@
|
|||
(t (error "CC Mode is incompatible with this version of Emacs")))
|
||||
map))
|
||||
|
||||
(defun c-define-abbrev-table (name defs)
|
||||
;; Compatibility wrapper for `define-abbrev' which passes a non-nil
|
||||
;; sixth argument for SYSTEM-FLAG in emacsen that support it
|
||||
;; (currently only Emacs 21.2).
|
||||
(define-abbrev-table name nil)
|
||||
(let ((table (symbol-value name)))
|
||||
(while defs
|
||||
(condition-case nil
|
||||
(apply 'define-abbrev table (append (car defs) '(t)))
|
||||
(wrong-number-of-arguments
|
||||
(apply 'define-abbrev table (car defs))))
|
||||
(setq defs (cdr defs)))))
|
||||
|
||||
(if c-mode-base-map
|
||||
nil
|
||||
;; TBD: should we even worry about naming this keymap. My vote: no,
|
||||
|
|
@ -181,6 +201,12 @@
|
|||
(substitute-key-definition 'indent-new-comment-line
|
||||
'c-indent-new-comment-line
|
||||
c-mode-base-map global-map)
|
||||
(when (fboundp 'comment-indent-new-line)
|
||||
;; indent-new-comment-line has changed name to
|
||||
;; comment-indent-new-line in Emacs 21.
|
||||
(substitute-key-definition 'comment-indent-new-line
|
||||
'c-indent-new-comment-line
|
||||
c-mode-base-map global-map))
|
||||
;; RMS says don't make these the default.
|
||||
;; (define-key c-mode-base-map "\e\C-a" 'c-beginning-of-defun)
|
||||
;; (define-key c-mode-base-map "\e\C-e" 'c-end-of-defun)
|
||||
|
|
@ -243,7 +269,7 @@
|
|||
(comment-region (region-beginning) (region-end) '(4))
|
||||
(c-fn-region-is-active-p)]
|
||||
["Fill Comment Paragraph" c-fill-paragraph t]
|
||||
"---"
|
||||
"----"
|
||||
["Indent Expression" c-indent-exp
|
||||
(memq (char-after) '(?\( ?\[ ?\{))]
|
||||
["Indent Line or Region" c-indent-line-or-region t]
|
||||
|
|
@ -252,18 +278,25 @@
|
|||
["Forward Conditional" c-forward-conditional t]
|
||||
["Backward Statement" c-beginning-of-statement t]
|
||||
["Forward Statement" c-end-of-statement t]
|
||||
"---"
|
||||
"----"
|
||||
["Macro Expand Region" c-macro-expand (c-fn-region-is-active-p)]
|
||||
["Backslashify" c-backslash-region
|
||||
(c-fn-region-is-active-p)]
|
||||
"----"
|
||||
("Toggle..."
|
||||
["Syntactic indentation" c-toggle-syntactic-indentation t]
|
||||
["Auto newline" c-toggle-auto-state t]
|
||||
["Hungry delete" c-toggle-hungry-state t])
|
||||
)))
|
||||
(cons modestr m)))
|
||||
|
||||
;; We don't require the outline package, but we configure it a bit anyway.
|
||||
(cc-bytecomp-defvar outline-level)
|
||||
|
||||
(defun c-common-init ()
|
||||
(defun c-common-init (mode)
|
||||
;; Common initializations for all modes.
|
||||
(setq c-buffer-is-cc-mode mode)
|
||||
|
||||
;; these variables should always be buffer local; they do not affect
|
||||
;; indentation style.
|
||||
(make-local-variable 'require-final-newline)
|
||||
|
|
@ -284,12 +317,14 @@
|
|||
(make-local-variable 'adaptive-fill-mode)
|
||||
(make-local-variable 'adaptive-fill-regexp)
|
||||
(make-local-variable 'imenu-generic-expression) ;set in the mode functions
|
||||
|
||||
;; X/Emacs 20 only
|
||||
(and (boundp 'comment-line-break-function)
|
||||
(progn
|
||||
(make-local-variable 'comment-line-break-function)
|
||||
(setq comment-line-break-function
|
||||
'c-indent-new-comment-line)))
|
||||
|
||||
;; now set their values
|
||||
(setq require-final-newline t
|
||||
parse-sexp-ignore-comments t
|
||||
|
|
@ -301,10 +336,14 @@
|
|||
comment-column 32
|
||||
comment-start-skip "/\\*+ *\\|//+ *"
|
||||
comment-multi-line t)
|
||||
|
||||
;; Fix keyword regexps.
|
||||
(c-init-language-vars)
|
||||
|
||||
;; now set the mode style based on c-default-style
|
||||
(let ((style (if (stringp c-default-style)
|
||||
c-default-style
|
||||
(or (cdr (assq major-mode c-default-style))
|
||||
(or (cdr (assq mode c-default-style))
|
||||
(cdr (assq 'other c-default-style))
|
||||
"gnu"))))
|
||||
;; Override style variables if `c-old-style-variable-behavior' is
|
||||
|
|
@ -319,56 +358,29 @@
|
|||
c-indentation-style
|
||||
(not (string-equal c-indentation-style
|
||||
style)))))))
|
||||
;; Fix things up for paragraph recognition and filling inside
|
||||
;; comments by using c-current-comment-prefix in the relevant
|
||||
;; places. We use adaptive filling for this to make it possible to
|
||||
;; use filladapt or some other fancy package.
|
||||
(setq c-current-comment-prefix
|
||||
(if (listp c-comment-prefix-regexp)
|
||||
(cdr-safe (or (assoc major-mode c-comment-prefix-regexp)
|
||||
(assoc 'other c-comment-prefix-regexp)))
|
||||
c-comment-prefix-regexp))
|
||||
(let ((comment-line-prefix
|
||||
(concat "[ \t]*\\(" c-current-comment-prefix "\\)[ \t]*")))
|
||||
(setq paragraph-start (concat comment-line-prefix
|
||||
c-append-paragraph-start
|
||||
"\\|"
|
||||
page-delimiter)
|
||||
paragraph-separate (concat comment-line-prefix
|
||||
c-append-paragraph-separate
|
||||
"\\|"
|
||||
page-delimiter)
|
||||
paragraph-ignore-fill-prefix t
|
||||
adaptive-fill-mode t
|
||||
adaptive-fill-regexp
|
||||
(concat comment-line-prefix
|
||||
(if adaptive-fill-regexp
|
||||
(concat "\\(" adaptive-fill-regexp "\\)")
|
||||
"")))
|
||||
(when (boundp 'adaptive-fill-first-line-regexp)
|
||||
;; XEmacs (20.x) adaptive fill mode doesn't have this.
|
||||
(make-local-variable 'adaptive-fill-first-line-regexp)
|
||||
(setq adaptive-fill-first-line-regexp
|
||||
(concat "\\`" comment-line-prefix
|
||||
;; Maybe we should incorporate the old value here,
|
||||
;; but then we have to do all sorts of kludges to
|
||||
;; deal with the \` and \' it probably contains.
|
||||
"\\'"))))
|
||||
(c-setup-paragraph-variables)
|
||||
|
||||
;; we have to do something special for c-offsets-alist so that the
|
||||
;; buffer local value has its own alist structure.
|
||||
(setq c-offsets-alist (copy-alist c-offsets-alist))
|
||||
|
||||
;; setup the comment indent variable in a Emacs version portable way
|
||||
;; ignore any byte compiler warnings you might get here
|
||||
(make-local-variable 'comment-indent-function)
|
||||
(setq comment-indent-function 'c-comment-indent)
|
||||
|
||||
;; add menus to menubar
|
||||
(easy-menu-add (c-mode-menu mode-name))
|
||||
|
||||
;; put auto-hungry designators onto minor-mode-alist, but only once
|
||||
(or (assq 'c-auto-hungry-string minor-mode-alist)
|
||||
(setq minor-mode-alist
|
||||
(cons '(c-auto-hungry-string c-auto-hungry-string)
|
||||
minor-mode-alist)))
|
||||
)
|
||||
|
||||
;; Install the function that ensures `c-state-cache' doesn't become
|
||||
;; invalid.
|
||||
(make-local-variable 'after-change-functions)
|
||||
(add-hook 'after-change-functions 'c-check-state-cache))
|
||||
|
||||
(defun c-postprocess-file-styles ()
|
||||
"Function that post processes relevant file local variables.
|
||||
|
|
@ -385,10 +397,10 @@ Note that the style variables are always made local to the buffer."
|
|||
(c-set-style c-file-style))
|
||||
(and c-file-offsets
|
||||
(mapcar
|
||||
(lambda (langentry)
|
||||
(let ((langelem (car langentry))
|
||||
(offset (cdr langentry)))
|
||||
(c-set-offset langelem offset)))
|
||||
(lambda (langentry)
|
||||
(let ((langelem (car langentry))
|
||||
(offset (cdr langentry)))
|
||||
(c-set-offset langelem offset)))
|
||||
c-file-offsets)))
|
||||
|
||||
(add-hook 'hack-local-variables-hook 'c-postprocess-file-styles)
|
||||
|
|
@ -398,9 +410,9 @@ Note that the style variables are always made local to the buffer."
|
|||
|
||||
(defvar c-mode-abbrev-table nil
|
||||
"Abbreviation table used in c-mode buffers.")
|
||||
(define-abbrev-table 'c-mode-abbrev-table
|
||||
'(("else" "else" c-electric-continued-statement 0 t)
|
||||
("while" "while" c-electric-continued-statement 0 t)))
|
||||
(c-define-abbrev-table 'c-mode-abbrev-table
|
||||
'(("else" "else" c-electric-continued-statement 0)
|
||||
("while" "while" c-electric-continued-statement 0)))
|
||||
|
||||
(defvar c-mode-map ()
|
||||
"Keymap used in c-mode buffers.")
|
||||
|
|
@ -431,24 +443,15 @@ run first.
|
|||
Key bindings:
|
||||
\\{c-mode-map}"
|
||||
(interactive)
|
||||
(c-initialize-cc-mode)
|
||||
(kill-all-local-variables)
|
||||
(c-initialize-cc-mode)
|
||||
(set-syntax-table c-mode-syntax-table)
|
||||
(setq major-mode 'c-mode
|
||||
mode-name "C"
|
||||
local-abbrev-table c-mode-abbrev-table
|
||||
abbrev-mode t)
|
||||
(use-local-map c-mode-map)
|
||||
(c-common-init)
|
||||
(setq comment-start "/* "
|
||||
comment-end " */"
|
||||
c-keywords (c-identifier-re c-C-keywords)
|
||||
c-conditional-key c-C-conditional-key
|
||||
c-class-key c-C-class-key
|
||||
c-baseclass-key nil
|
||||
c-comment-start-regexp c-C-comment-start-regexp
|
||||
c-bitfield-key c-C-bitfield-key
|
||||
)
|
||||
(c-common-init 'c-mode)
|
||||
(cc-imenu-init cc-imenu-c-generic-expression)
|
||||
(run-hooks 'c-mode-common-hook)
|
||||
(run-hooks 'c-mode-hook)
|
||||
|
|
@ -459,10 +462,10 @@ Key bindings:
|
|||
|
||||
(defvar c++-mode-abbrev-table nil
|
||||
"Abbreviation table used in c++-mode buffers.")
|
||||
(define-abbrev-table 'c++-mode-abbrev-table
|
||||
'(("else" "else" c-electric-continued-statement 0 t)
|
||||
("while" "while" c-electric-continued-statement 0 t)
|
||||
("catch" "catch" c-electric-continued-statement 0 t)))
|
||||
(c-define-abbrev-table 'c++-mode-abbrev-table
|
||||
'(("else" "else" c-electric-continued-statement 0)
|
||||
("while" "while" c-electric-continued-statement 0)
|
||||
("catch" "catch" c-electric-continued-statement 0)))
|
||||
|
||||
(defvar c++-mode-map ()
|
||||
"Keymap used in c++-mode buffers.")
|
||||
|
|
@ -496,26 +499,15 @@ variable is bound and has a non-nil value. Also the hook
|
|||
Key bindings:
|
||||
\\{c++-mode-map}"
|
||||
(interactive)
|
||||
(c-initialize-cc-mode)
|
||||
(kill-all-local-variables)
|
||||
(c-initialize-cc-mode)
|
||||
(set-syntax-table c++-mode-syntax-table)
|
||||
(setq major-mode 'c++-mode
|
||||
mode-name "C++"
|
||||
local-abbrev-table c++-mode-abbrev-table
|
||||
abbrev-mode t)
|
||||
(use-local-map c++-mode-map)
|
||||
(c-common-init)
|
||||
(setq comment-start "// "
|
||||
comment-end ""
|
||||
c-keywords (c-identifier-re c-C++-keywords)
|
||||
c-conditional-key c-C++-conditional-key
|
||||
c-comment-start-regexp c-C++-comment-start-regexp
|
||||
c-class-key c-C++-class-key
|
||||
c-extra-toplevel-key c-C++-extra-toplevel-key
|
||||
c-access-key c-C++-access-key
|
||||
c-recognize-knr-p nil
|
||||
c-bitfield-key c-C-bitfield-key
|
||||
)
|
||||
(c-common-init 'c++-mode)
|
||||
(cc-imenu-init cc-imenu-c++-generic-expression)
|
||||
(run-hooks 'c-mode-common-hook)
|
||||
(run-hooks 'c++-mode-hook)
|
||||
|
|
@ -526,9 +518,9 @@ Key bindings:
|
|||
|
||||
(defvar objc-mode-abbrev-table nil
|
||||
"Abbreviation table used in objc-mode buffers.")
|
||||
(define-abbrev-table 'objc-mode-abbrev-table
|
||||
'(("else" "else" c-electric-continued-statement 0 t)
|
||||
("while" "while" c-electric-continued-statement 0 t)))
|
||||
(c-define-abbrev-table 'objc-mode-abbrev-table
|
||||
'(("else" "else" c-electric-continued-statement 0)
|
||||
("while" "while" c-electric-continued-statement 0)))
|
||||
|
||||
(defvar objc-mode-map ()
|
||||
"Keymap used in objc-mode buffers.")
|
||||
|
|
@ -559,25 +551,15 @@ is run first.
|
|||
Key bindings:
|
||||
\\{objc-mode-map}"
|
||||
(interactive)
|
||||
(c-initialize-cc-mode)
|
||||
(kill-all-local-variables)
|
||||
(c-initialize-cc-mode)
|
||||
(set-syntax-table objc-mode-syntax-table)
|
||||
(setq major-mode 'objc-mode
|
||||
mode-name "ObjC"
|
||||
local-abbrev-table objc-mode-abbrev-table
|
||||
abbrev-mode t)
|
||||
(use-local-map objc-mode-map)
|
||||
(c-common-init)
|
||||
(setq comment-start "// "
|
||||
comment-end ""
|
||||
c-keywords (c-identifier-re c-ObjC-keywords)
|
||||
c-conditional-key c-ObjC-conditional-key
|
||||
c-comment-start-regexp c-ObjC-comment-start-regexp
|
||||
c-class-key c-ObjC-class-key
|
||||
c-baseclass-key nil
|
||||
c-access-key c-ObjC-access-key
|
||||
c-method-key c-ObjC-method-key
|
||||
)
|
||||
(c-common-init 'objc-mode)
|
||||
(cc-imenu-init cc-imenu-objc-generic-expression)
|
||||
(run-hooks 'c-mode-common-hook)
|
||||
(run-hooks 'objc-mode-hook)
|
||||
|
|
@ -588,11 +570,11 @@ Key bindings:
|
|||
|
||||
(defvar java-mode-abbrev-table nil
|
||||
"Abbreviation table used in java-mode buffers.")
|
||||
(define-abbrev-table 'java-mode-abbrev-table
|
||||
'(("else" "else" c-electric-continued-statement 0 t)
|
||||
("while" "while" c-electric-continued-statement 0 t)
|
||||
("catch" "catch" c-electric-continued-statement 0 t)
|
||||
("finally" "finally" c-electric-continued-statement 0 t)))
|
||||
(c-define-abbrev-table 'java-mode-abbrev-table
|
||||
'(("else" "else" c-electric-continued-statement 0)
|
||||
("while" "while" c-electric-continued-statement 0)
|
||||
("catch" "catch" c-electric-continued-statement 0)
|
||||
("finally" "finally" c-electric-continued-statement 0)))
|
||||
|
||||
(defvar java-mode-map ()
|
||||
"Keymap used in java-mode buffers.")
|
||||
|
|
@ -625,28 +607,15 @@ set styles in `c-mode-common-hook'.
|
|||
Key bindings:
|
||||
\\{java-mode-map}"
|
||||
(interactive)
|
||||
(c-initialize-cc-mode)
|
||||
(kill-all-local-variables)
|
||||
(c-initialize-cc-mode)
|
||||
(set-syntax-table java-mode-syntax-table)
|
||||
(setq major-mode 'java-mode
|
||||
mode-name "Java"
|
||||
local-abbrev-table java-mode-abbrev-table
|
||||
abbrev-mode t
|
||||
c-append-paragraph-start c-Java-javadoc-paragraph-start)
|
||||
abbrev-mode t)
|
||||
(use-local-map java-mode-map)
|
||||
(c-common-init)
|
||||
(setq comment-start "// "
|
||||
comment-end ""
|
||||
c-keywords (c-identifier-re c-Java-keywords)
|
||||
c-conditional-key c-Java-conditional-key
|
||||
c-comment-start-regexp c-Java-comment-start-regexp
|
||||
c-class-key c-Java-class-key
|
||||
c-method-key nil
|
||||
c-baseclass-key nil
|
||||
c-recognize-knr-p nil
|
||||
c-inexpr-class-key c-Java-inexpr-class-key
|
||||
;defun-prompt-regexp c-Java-defun-prompt-regexp
|
||||
)
|
||||
(c-common-init 'java-mode)
|
||||
(cc-imenu-init cc-imenu-java-generic-expression)
|
||||
(run-hooks 'c-mode-common-hook)
|
||||
(run-hooks 'java-mode-hook)
|
||||
|
|
@ -657,7 +626,7 @@ Key bindings:
|
|||
|
||||
(defvar idl-mode-abbrev-table nil
|
||||
"Abbreviation table used in idl-mode buffers.")
|
||||
(define-abbrev-table 'idl-mode-abbrev-table ())
|
||||
(c-define-abbrev-table 'idl-mode-abbrev-table nil)
|
||||
|
||||
(defvar idl-mode-map ()
|
||||
"Keymap used in idl-mode buffers.")
|
||||
|
|
@ -688,25 +657,14 @@ variable is bound and has a non-nil value. Also the hook
|
|||
Key bindings:
|
||||
\\{idl-mode-map}"
|
||||
(interactive)
|
||||
(c-initialize-cc-mode)
|
||||
(kill-all-local-variables)
|
||||
(c-initialize-cc-mode)
|
||||
(set-syntax-table idl-mode-syntax-table)
|
||||
(setq major-mode 'idl-mode
|
||||
mode-name "IDL"
|
||||
local-abbrev-table idl-mode-abbrev-table)
|
||||
(use-local-map idl-mode-map)
|
||||
(c-common-init)
|
||||
(setq comment-start "// "
|
||||
comment-end ""
|
||||
c-keywords (c-identifier-re c-IDL-keywords)
|
||||
c-conditional-key c-IDL-conditional-key
|
||||
c-comment-start-regexp c-IDL-comment-start-regexp
|
||||
c-class-key c-IDL-class-key
|
||||
c-method-key nil
|
||||
c-baseclass-key nil
|
||||
c-extra-toplevel-key c-IDL-extra-toplevel-key
|
||||
c-recognize-knr-p nil
|
||||
)
|
||||
(c-common-init 'idl-mode)
|
||||
;;(cc-imenu-init cc-imenu-idl-generic-expression) ;FIXME
|
||||
(run-hooks 'c-mode-common-hook)
|
||||
(run-hooks 'idl-mode-hook)
|
||||
|
|
@ -717,9 +675,9 @@ Key bindings:
|
|||
|
||||
(defvar pike-mode-abbrev-table nil
|
||||
"Abbreviation table used in pike-mode buffers.")
|
||||
(define-abbrev-table 'pike-mode-abbrev-table
|
||||
'(("else" "else" c-electric-continued-statement 0 t)
|
||||
("while" "while" c-electric-continued-statement 0 t)))
|
||||
(c-define-abbrev-table 'pike-mode-abbrev-table
|
||||
'(("else" "else" c-electric-continued-statement 0)
|
||||
("while" "while" c-electric-continued-statement 0)))
|
||||
|
||||
(defvar pike-mode-map ()
|
||||
"Keymap used in pike-mode buffers.")
|
||||
|
|
@ -735,8 +693,8 @@ Key bindings:
|
|||
;;;###autoload
|
||||
(defun pike-mode ()
|
||||
"Major mode for editing Pike code.
|
||||
To submit a problem report, enter `\\[c-submit-bug-report]' from an
|
||||
idl-mode buffer. This automatically sets up a mail buffer with
|
||||
To submit a problem report, enter `\\[c-submit-bug-report]' from a
|
||||
pike-mode buffer. This automatically sets up a mail buffer with
|
||||
version information already added. You just need to add a description
|
||||
of the problem, including a reproducible test case, and send the
|
||||
message.
|
||||
|
|
@ -750,80 +708,26 @@ is bound and has a non-nil value. Also the common hook
|
|||
Key bindings:
|
||||
\\{pike-mode-map}"
|
||||
(interactive)
|
||||
(c-initialize-cc-mode)
|
||||
(kill-all-local-variables)
|
||||
(c-initialize-cc-mode)
|
||||
(set-syntax-table pike-mode-syntax-table)
|
||||
(setq major-mode 'pike-mode
|
||||
mode-name "Pike"
|
||||
local-abbrev-table pike-mode-abbrev-table
|
||||
abbrev-mode t
|
||||
c-append-paragraph-start c-Pike-pikedoc-paragraph-start
|
||||
c-append-paragraph-separate c-Pike-pikedoc-paragraph-separate)
|
||||
abbrev-mode t)
|
||||
(use-local-map pike-mode-map)
|
||||
(c-common-init)
|
||||
(setq comment-start "// "
|
||||
comment-end ""
|
||||
c-keywords (c-identifier-re c-Pike-keywords)
|
||||
c-conditional-key c-Pike-conditional-key
|
||||
c-comment-start-regexp c-Pike-comment-start-regexp
|
||||
c-class-key c-Pike-class-key
|
||||
c-method-key nil
|
||||
c-baseclass-key nil
|
||||
c-recognize-knr-p nil
|
||||
c-lambda-key c-Pike-lambda-key
|
||||
c-inexpr-block-key c-Pike-inexpr-block-key
|
||||
c-inexpr-class-key c-Pike-inexpr-class-key
|
||||
c-special-brace-lists c-Pike-special-brace-lists
|
||||
)
|
||||
(c-common-init 'pike-mode)
|
||||
;;(cc-imenu-init cc-imenu-pike-generic-expression) ;FIXME
|
||||
(run-hooks 'c-mode-common-hook)
|
||||
(run-hooks 'pike-mode-hook)
|
||||
(c-update-modeline))
|
||||
|
||||
|
||||
;; Helper for setting up Filladapt mode. It's not used by CC Mode itself.
|
||||
|
||||
(cc-bytecomp-defvar filladapt-token-table)
|
||||
(cc-bytecomp-defvar filladapt-token-match-table)
|
||||
(cc-bytecomp-defvar filladapt-token-conversion-table)
|
||||
|
||||
(defun c-setup-filladapt ()
|
||||
"Convenience function to configure Kyle E. Jones' Filladapt mode for
|
||||
CC Mode by making sure the proper entries are present on
|
||||
`filladapt-token-table', `filladapt-token-match-table', and
|
||||
`filladapt-token-conversion-table'. This is intended to be used on
|
||||
`c-mode-common-hook' or similar."
|
||||
;; This function is intended to be used explicitly by the end user
|
||||
;; only.
|
||||
;;
|
||||
;; The default configuration already handles C++ comments, but we
|
||||
;; need to add handling of C block comments. A new filladapt token
|
||||
;; `c-comment' is added for that.
|
||||
(let (p)
|
||||
(setq p filladapt-token-table)
|
||||
(while (and p (not (eq (car-safe (cdr-safe (car-safe p))) 'c-comment)))
|
||||
(setq p (cdr-safe p)))
|
||||
(if p
|
||||
(setcar (car p) c-current-comment-prefix)
|
||||
(setq filladapt-token-table
|
||||
(append (list (car filladapt-token-table)
|
||||
(list c-current-comment-prefix 'c-comment))
|
||||
(cdr filladapt-token-table)))))
|
||||
(unless (assq 'c-comment filladapt-token-match-table)
|
||||
(setq filladapt-token-match-table
|
||||
(append '((c-comment c-comment))
|
||||
filladapt-token-match-table)))
|
||||
(unless (assq 'c-comment filladapt-token-conversion-table)
|
||||
(setq filladapt-token-conversion-table
|
||||
(append '((c-comment . exact))
|
||||
filladapt-token-conversion-table))))
|
||||
|
||||
|
||||
;; bug reporting
|
||||
|
||||
(defconst c-mode-help-address
|
||||
"bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org"
|
||||
"Addresses for CC Mode bug reports.")
|
||||
"bug-cc-mode@gnu.org"
|
||||
"Address(es) for CC Mode bug reports.")
|
||||
|
||||
(defun c-version ()
|
||||
"Echo the current version of CC Mode in the minibuffer."
|
||||
|
|
@ -892,9 +796,9 @@ CC Mode by making sure the proper entries are present on
|
|||
defun-prompt-regexp))
|
||||
vars)
|
||||
(lambda ()
|
||||
(run-hooks 'c-prepare-bug-report-hooks)
|
||||
(insert (format "Buffer Style: %s\n\nc-emacs-features: %s\n"
|
||||
style c-features)))))))
|
||||
(run-hooks 'c-prepare-bug-report-hooks)
|
||||
(insert (format "Buffer Style: %s\n\nc-emacs-features: %s\n"
|
||||
style c-features)))))))
|
||||
|
||||
|
||||
(cc-provide 'cc-mode)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program; see the file COPYING. If not, write to
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to
|
||||
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
|
|
@ -42,7 +42,14 @@
|
|||
(require 'cc-bytecomp)))
|
||||
|
||||
(cc-require 'cc-defs)
|
||||
(cc-require 'cc-langs)
|
||||
(cc-require 'cc-vars)
|
||||
(cc-require 'cc-align)
|
||||
;; cc-align is only indirectly required: Styles added with
|
||||
;; `c-add-style' often contains references to functions defined there.
|
||||
|
||||
;; Silence the compiler.
|
||||
(cc-bytecomp-defvar adaptive-fill-first-line-regexp) ; Emacs
|
||||
|
||||
|
||||
;; Warning: don't eval-defun this constant or you'll break style inheritance.
|
||||
|
|
@ -53,6 +60,7 @@
|
|||
(c-offsets-alist . ((statement-block-intro . +)
|
||||
(knr-argdecl-intro . 5)
|
||||
(substatement-open . +)
|
||||
(substatement-label . 0)
|
||||
(label . 0)
|
||||
(statement-case-open . +)
|
||||
(statement-cont . +)
|
||||
|
|
@ -70,6 +78,7 @@
|
|||
(c-offsets-alist . ((statement-block-intro . +)
|
||||
(knr-argdecl-intro . 0)
|
||||
(substatement-open . 0)
|
||||
(substatement-label . 0)
|
||||
(label . 0)
|
||||
(statement-cont . +)
|
||||
))
|
||||
|
|
@ -80,6 +89,7 @@
|
|||
(c-offsets-alist . ((statement-block-intro . +)
|
||||
(knr-argdecl-intro . +)
|
||||
(substatement-open . 0)
|
||||
(substatement-label . 0)
|
||||
(label . 0)
|
||||
(statement-cont . +)
|
||||
(inline-open . 0)
|
||||
|
|
@ -91,6 +101,7 @@
|
|||
(c-comment-only-line-offset . 0)
|
||||
(c-offsets-alist . ((statement-block-intro . +)
|
||||
(substatement-open . 0)
|
||||
(substatement-label . 0)
|
||||
(label . 0)
|
||||
(statement-cont . +)
|
||||
))
|
||||
|
|
@ -102,6 +113,7 @@
|
|||
(label . 0)
|
||||
(statement-cont . +)
|
||||
(substatement-open . +)
|
||||
(substatement-label . +)
|
||||
(block-open . +)
|
||||
(statement-block-intro . c-lineup-whitesmith-in-block)
|
||||
(block-close . c-lineup-whitesmith-in-block)
|
||||
|
|
@ -130,8 +142,7 @@
|
|||
(c-comment-only-line-offset . 0)
|
||||
(c-hanging-braces-alist . ((substatement-open before after)))
|
||||
(c-offsets-alist . ((topmost-intro . 0)
|
||||
(topmost-intro-cont . 0)
|
||||
(substatement . +)
|
||||
(substatement . +)
|
||||
(substatement-open . 0)
|
||||
(case-label . +)
|
||||
(access-label . -)
|
||||
|
|
@ -150,6 +161,7 @@
|
|||
(c-offsets-alist . ((statement-block-intro . +)
|
||||
(knr-argdecl-intro . 0)
|
||||
(substatement-open . 0)
|
||||
(substatement-label . 0)
|
||||
(label . 0)
|
||||
(statement-cont . +)
|
||||
))
|
||||
|
|
@ -180,7 +192,8 @@
|
|||
(topmost-intro-cont . +)
|
||||
(statement-block-intro . +)
|
||||
(knr-argdecl-intro . 5)
|
||||
(substatement-open . +)
|
||||
(substatement-open . +)
|
||||
(substatement-label . +)
|
||||
(label . +)
|
||||
(statement-case-open . +)
|
||||
(statement-cont . +)
|
||||
|
|
@ -225,7 +238,6 @@ to add new styles or modify existing styles (it is not a good idea to
|
|||
modify existing styles -- you should create a new style that inherits
|
||||
the existing style.")
|
||||
|
||||
|
||||
|
||||
;; Functions that manipulate styles
|
||||
(defun c-set-style-1 (conscell dont-override)
|
||||
|
|
@ -257,29 +269,33 @@ the existing style.")
|
|||
(mapcar add-func (if dont-override (reverse val) val))
|
||||
(funcall add-func val))))
|
||||
;; all other variables
|
||||
(t (if (or (not dont-override)
|
||||
(not (memq attr c-style-variables))
|
||||
(eq (symbol-value attr) 'set-from-style))
|
||||
(set attr val))))
|
||||
))
|
||||
(t (when (or (not dont-override)
|
||||
(not (memq attr c-style-variables))
|
||||
(eq (symbol-value attr) 'set-from-style))
|
||||
(set attr val)
|
||||
;; Must update a number of other variables if
|
||||
;; c-comment-prefix-regexp is set.
|
||||
(if (eq attr 'c-comment-prefix-regexp)
|
||||
(c-setup-paragraph-variables)))))))
|
||||
|
||||
(defun c-get-style-variables (style basestyles)
|
||||
;; Return all variables in a style by resolving inheritances.
|
||||
(let ((vars (cdr (or (assoc (downcase style) c-style-alist)
|
||||
(assoc (upcase style) c-style-alist)
|
||||
(assoc style c-style-alist)
|
||||
(error "Undefined style: %s" style)))))
|
||||
(if (string-equal style "user")
|
||||
(copy-alist vars)
|
||||
(let ((base (if (stringp (car vars))
|
||||
(prog1
|
||||
(downcase (car vars))
|
||||
(setq vars (cdr vars)))
|
||||
"user")))
|
||||
(if (not style)
|
||||
(copy-alist c-fallback-style)
|
||||
(let ((vars (cdr (or (assoc (downcase style) c-style-alist)
|
||||
(assoc (upcase style) c-style-alist)
|
||||
(assoc style c-style-alist)
|
||||
(progn
|
||||
(c-benign-error "Undefined style: %s" style)
|
||||
nil)))))
|
||||
(let ((base (and (stringp (car-safe vars))
|
||||
(prog1
|
||||
(downcase (car vars))
|
||||
(setq vars (cdr vars))))))
|
||||
(if (memq base basestyles)
|
||||
(error "Style loop detected: %s in %s" base basestyles))
|
||||
(nconc (c-get-style-variables base (cons base basestyles))
|
||||
(copy-alist vars))))))
|
||||
(c-benign-error "Style loop detected: %s in %s" base basestyles)
|
||||
(nconc (c-get-style-variables base (cons base basestyles))
|
||||
(copy-alist vars)))))))
|
||||
|
||||
(defvar c-set-style-history nil)
|
||||
|
||||
|
|
@ -302,15 +318,33 @@ will be reassigned.
|
|||
Obviously, specifying DONT-OVERRIDE is useful mainly when the initial
|
||||
style is chosen for a CC Mode buffer by a major mode. Since this is
|
||||
done internally by CC Mode, there's hardly ever a reason to use it."
|
||||
(interactive (list (let ((completion-ignore-case t)
|
||||
(prompt (format "Which %s indentation style? "
|
||||
mode-name)))
|
||||
(completing-read prompt c-style-alist nil t
|
||||
nil
|
||||
'c-set-style-history
|
||||
c-indentation-style))))
|
||||
(interactive
|
||||
(list (let ((completion-ignore-case t)
|
||||
(prompt (format "Which %s indentation style? "
|
||||
mode-name)))
|
||||
(condition-case nil
|
||||
;; The default argument is preferred over
|
||||
;; initial-contents, but it only exists in Emacs >= 20
|
||||
;; and XEmacs >= 21.
|
||||
(completing-read prompt c-style-alist nil t nil
|
||||
'c-set-style-history
|
||||
c-indentation-style)
|
||||
(wrong-number-of-arguments
|
||||
;; If the call above failed, we fall back to the old way
|
||||
;; of specifying the default value.
|
||||
(completing-read prompt c-style-alist nil t
|
||||
(cons c-indentation-style 0)
|
||||
'c-set-style-history))))))
|
||||
(c-initialize-builtin-style)
|
||||
(let ((vars (c-get-style-variables stylename nil)))
|
||||
(unless dont-override
|
||||
;; Since we always add to c-special-indent-hook we must reset it
|
||||
;; first, or else the hooks from the preceding style will
|
||||
;; remain. This is not necessary for c-offsets-alist, since
|
||||
;; c-get-style-variables contains every valid offset type in the
|
||||
;; fallback entry.
|
||||
(setq c-special-indent-hook
|
||||
(default-value 'c-special-indent-hook)))
|
||||
(mapcar (lambda (elem)
|
||||
(c-set-style-1 elem dont-override))
|
||||
;; Need to go through the variables backwards when we
|
||||
|
|
@ -343,7 +377,6 @@ STYLE using `c-set-style' if the optional SET-P flag is non-nil."
|
|||
(setq c-style-alist (cons (cons style descrip) c-style-alist))))
|
||||
(and set-p (c-set-style style)))
|
||||
|
||||
|
||||
|
||||
(defvar c-read-offset-history nil)
|
||||
|
||||
|
|
@ -359,35 +392,24 @@ STYLE using `c-set-style' if the optional SET-P flag is non-nil."
|
|||
"or [+,-,++,--,*,/] "
|
||||
defstr))
|
||||
(prompt (concat symname " offset " defstr))
|
||||
offset input interned raw)
|
||||
(keymap (make-sparse-keymap))
|
||||
(minibuffer-completion-table obarray)
|
||||
(minibuffer-completion-predicate 'fboundp)
|
||||
offset input)
|
||||
;; In principle completing-read is used here, but SPC is unbound
|
||||
;; to make it less annoying to enter lists.
|
||||
(set-keymap-parent keymap minibuffer-local-completion-map)
|
||||
(define-key keymap " " 'self-insert-command)
|
||||
(while (not offset)
|
||||
(setq input (completing-read prompt obarray 'fboundp nil nil
|
||||
'c-read-offset-history)
|
||||
offset (cond ((string-equal "" input) oldoff) ; default
|
||||
((string-equal "+" input) '+)
|
||||
((string-equal "-" input) '-)
|
||||
((string-equal "++" input) '++)
|
||||
((string-equal "--" input) '--)
|
||||
((string-equal "*" input) '*)
|
||||
((string-equal "/" input) '/)
|
||||
((string-match "^-?[0-9]+$" input)
|
||||
(string-to-int input))
|
||||
;; a symbol with a function binding
|
||||
((fboundp (setq interned (intern input)))
|
||||
interned)
|
||||
;; a symbol with variable binding
|
||||
((boundp interned) interned)
|
||||
;; a lambda function or a vector
|
||||
((progn
|
||||
(c-safe (setq raw (read input)))
|
||||
(or (functionp raw)
|
||||
(vectorp raw)))
|
||||
raw)
|
||||
;; error, but don't signal one, keep trying
|
||||
;; to read an input value
|
||||
(t (ding)
|
||||
(setq prompt errmsg)
|
||||
nil))))
|
||||
(setq input (read-from-minibuffer prompt nil keymap t
|
||||
'c-read-offset-history
|
||||
(format "%s" oldoff)))
|
||||
(if (c-valid-offset input)
|
||||
(setq offset input)
|
||||
;; error, but don't signal one, keep trying
|
||||
;; to read an input value
|
||||
(ding)
|
||||
(setq prompt errmsg)))
|
||||
offset))
|
||||
|
||||
;;;###autoload
|
||||
|
|
@ -418,18 +440,94 @@ and exists only for compatibility reasons."
|
|||
(offset (c-read-offset langelem)))
|
||||
(list langelem offset current-prefix-arg)))
|
||||
;; sanity check offset
|
||||
(unless (c-valid-offset offset)
|
||||
(error (concat "Offset must be int, func, var, vector, list, "
|
||||
"or in [+,-,++,--,*,/]: %s")
|
||||
offset))
|
||||
(let ((entry (assq symbol c-offsets-alist)))
|
||||
(if entry
|
||||
(setcdr entry offset)
|
||||
(if (assq symbol (get 'c-offsets-alist 'c-stylevar-fallback))
|
||||
(setq c-offsets-alist (cons (cons symbol offset) c-offsets-alist))
|
||||
(error "%s is not a valid syntactic symbol" symbol))))
|
||||
(if (c-valid-offset offset)
|
||||
(let ((entry (assq symbol c-offsets-alist)))
|
||||
(if entry
|
||||
(setcdr entry offset)
|
||||
(if (assq symbol (get 'c-offsets-alist 'c-stylevar-fallback))
|
||||
(setq c-offsets-alist (cons (cons symbol offset)
|
||||
c-offsets-alist))
|
||||
(c-benign-error "%s is not a valid syntactic symbol" symbol))))
|
||||
(c-benign-error "Invalid indentation setting for symbol %s: %s"
|
||||
symbol offset))
|
||||
(c-keep-region-active))
|
||||
|
||||
|
||||
(defun c-setup-paragraph-variables ()
|
||||
"Fix things up for paragraph recognition and filling inside comments by
|
||||
incorporating the value of `c-comment-prefix-regexp' in the relevant
|
||||
variables."
|
||||
(setq c-current-comment-prefix
|
||||
(if (listp c-comment-prefix-regexp)
|
||||
(cdr-safe (or (assoc major-mode c-comment-prefix-regexp)
|
||||
(assoc 'other c-comment-prefix-regexp)))
|
||||
c-comment-prefix-regexp))
|
||||
(let ((comment-line-prefix
|
||||
(concat "[ \t]*\\(" c-current-comment-prefix "\\)[ \t]*")))
|
||||
(setq paragraph-start (concat comment-line-prefix
|
||||
(c-lang-var paragraph-start)
|
||||
"\\|"
|
||||
page-delimiter)
|
||||
paragraph-separate (concat comment-line-prefix
|
||||
(c-lang-var paragraph-separate)
|
||||
"\\|"
|
||||
page-delimiter)
|
||||
paragraph-ignore-fill-prefix t
|
||||
adaptive-fill-mode t
|
||||
adaptive-fill-regexp
|
||||
(concat comment-line-prefix
|
||||
(if (default-value 'adaptive-fill-regexp)
|
||||
(concat "\\("
|
||||
(default-value 'adaptive-fill-regexp)
|
||||
"\\)")
|
||||
"")))
|
||||
(when (boundp 'adaptive-fill-first-line-regexp)
|
||||
;; XEmacs (20.x) adaptive fill mode doesn't have this.
|
||||
(make-local-variable 'adaptive-fill-first-line-regexp)
|
||||
(setq adaptive-fill-first-line-regexp
|
||||
(concat "\\`" comment-line-prefix
|
||||
;; Maybe we should incorporate the old value here,
|
||||
;; but then we have to do all sorts of kludges to
|
||||
;; deal with the \` and \' it probably contains.
|
||||
"\\'")))))
|
||||
|
||||
|
||||
;; Helper for setting up Filladapt mode. It's not used by CC Mode itself.
|
||||
|
||||
(cc-bytecomp-defvar filladapt-token-table)
|
||||
(cc-bytecomp-defvar filladapt-token-match-table)
|
||||
(cc-bytecomp-defvar filladapt-token-conversion-table)
|
||||
|
||||
(defun c-setup-filladapt ()
|
||||
"Convenience function to configure Kyle E. Jones' Filladapt mode for
|
||||
CC Mode by making sure the proper entries are present on
|
||||
`filladapt-token-table', `filladapt-token-match-table', and
|
||||
`filladapt-token-conversion-table'. This is intended to be used on
|
||||
`c-mode-common-hook' or similar."
|
||||
;; This function is intended to be used explicitly by the end user
|
||||
;; only.
|
||||
;;
|
||||
;; The default configuration already handles C++ comments, but we
|
||||
;; need to add handling of C block comments. A new filladapt token
|
||||
;; `c-comment' is added for that.
|
||||
(let (p)
|
||||
(setq p filladapt-token-table)
|
||||
(while (and p (not (eq (car-safe (cdr-safe (car-safe p))) 'c-comment)))
|
||||
(setq p (cdr-safe p)))
|
||||
(if p
|
||||
(setcar (car p) c-current-comment-prefix)
|
||||
(setq filladapt-token-table
|
||||
(append (list (car filladapt-token-table)
|
||||
(list c-current-comment-prefix 'c-comment))
|
||||
(cdr filladapt-token-table)))))
|
||||
(unless (assq 'c-comment filladapt-token-match-table)
|
||||
(setq filladapt-token-match-table
|
||||
(append '((c-comment c-comment))
|
||||
filladapt-token-match-table)))
|
||||
(unless (assq 'c-comment filladapt-token-conversion-table)
|
||||
(setq filladapt-token-conversion-table
|
||||
(append '((c-comment . exact))
|
||||
filladapt-token-conversion-table))))
|
||||
|
||||
|
||||
(defun c-initialize-builtin-style ()
|
||||
|
|
@ -440,31 +538,22 @@ and exists only for compatibility reasons."
|
|||
(unless (get 'c-initialize-builtin-style 'is-run)
|
||||
(put 'c-initialize-builtin-style 'is-run t)
|
||||
;;(c-initialize-cc-mode)
|
||||
(or (assoc "cc-mode" c-style-alist)
|
||||
(assoc "user" c-style-alist)
|
||||
(progn
|
||||
(c-add-style
|
||||
"user"
|
||||
(mapcar
|
||||
(lambda (var)
|
||||
(let ((val (symbol-value var)))
|
||||
(cons var
|
||||
(cond ((eq var 'c-offsets-alist)
|
||||
(mapcar
|
||||
(lambda (langentry)
|
||||
(setq langentry (or (assq (car langentry) val)
|
||||
langentry))
|
||||
(cons (car langentry)
|
||||
(cdr langentry)))
|
||||
(get var 'c-stylevar-fallback)))
|
||||
((eq var 'c-special-indent-hook)
|
||||
val)
|
||||
(t
|
||||
(if (eq val 'set-from-style)
|
||||
(get var 'c-stylevar-fallback)
|
||||
val))))))
|
||||
c-style-variables))
|
||||
(c-add-style "cc-mode" '("user"))))
|
||||
(unless (assoc "user" c-style-alist)
|
||||
(let ((vars c-style-variables) var val uservars)
|
||||
(while vars
|
||||
(setq var (car vars)
|
||||
val (symbol-value var)
|
||||
vars (cdr vars))
|
||||
(cond ((eq var 'c-offsets-alist)
|
||||
(or (null val)
|
||||
(setq uservars (cons (cons 'c-offsets-alist val)
|
||||
uservars))))
|
||||
((not (eq val 'set-from-style))
|
||||
(setq uservars (cons (cons var val)
|
||||
uservars)))))
|
||||
(c-add-style "user" uservars)))
|
||||
(unless (assoc "cc-mode" c-style-alist)
|
||||
(c-add-style "cc-mode" '("user")))
|
||||
(if c-style-variables-are-local-p
|
||||
(c-make-styles-buffer-local))))
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
;; GNU General Public License for more details.
|
||||
|
||||
;; You should have received a copy of the GNU General Public License
|
||||
;; along with this program; see the file COPYING. If not, write to
|
||||
;; along with GNU Emacs; see the file COPYING. If not, write to
|
||||
;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
;; Boston, MA 02111-1307, USA.
|
||||
|
||||
|
|
@ -66,8 +66,20 @@ since a (good enough) custom library wasn't found")
|
|||
(cc-bytecomp-defmacro define-widget (name class doc &rest args))
|
||||
(cc-bytecomp-defmacro defcustom (symbol value doc &rest args)
|
||||
`(defvar ,symbol ,value ,doc))
|
||||
(cc-bytecomp-defmacro custom-declare-variable (symbol value doc
|
||||
&rest args)
|
||||
`(defvar ,(eval symbol) ,(eval value) ,doc))
|
||||
nil))))
|
||||
|
||||
(cc-eval-when-compile
|
||||
;; Need the function form of `backquote', which isn't standardized
|
||||
;; between Emacsen. It's called `bq-process' in XEmacs, and
|
||||
;; `backquote-process' in Emacs. `backquote-process' returns a
|
||||
;; slightly more convoluted form, so let `bq-process' be the norm.
|
||||
(if (fboundp 'backquote-process)
|
||||
(cc-bytecomp-defmacro bq-process (form)
|
||||
`(cdr (backquote-process ,form)))))
|
||||
|
||||
|
||||
;;; Helpers
|
||||
|
||||
|
|
@ -103,41 +115,56 @@ Useful as last item in a `choice' widget."
|
|||
(match-string 0 value)))
|
||||
value)))
|
||||
|
||||
(define-widget 'c-integer-or-nil 'sexp
|
||||
"An integer or the value nil."
|
||||
:value nil
|
||||
:tag "Optional integer"
|
||||
:match (lambda (widget value) (or (integerp value) (null value))))
|
||||
|
||||
(defvar c-style-variables
|
||||
'(c-basic-offset c-comment-only-line-offset c-block-comment-prefix
|
||||
'(c-basic-offset c-comment-only-line-offset c-indent-comment-alist
|
||||
c-indent-comments-syntactically-p c-block-comment-prefix
|
||||
c-comment-prefix-regexp c-cleanup-list c-hanging-braces-alist
|
||||
c-hanging-colons-alist c-hanging-semi&comma-criteria c-backslash-column
|
||||
c-special-indent-hook c-label-minimum-indentation c-offsets-alist)
|
||||
c-backslash-max-column c-special-indent-hook c-label-minimum-indentation
|
||||
c-offsets-alist)
|
||||
"List of the style variables.")
|
||||
|
||||
(defvar c-fallback-style nil)
|
||||
|
||||
(defsubst c-set-stylevar-fallback (name val)
|
||||
(put name 'c-stylevar-fallback val)
|
||||
(setq c-fallback-style (cons (cons name val) c-fallback-style)))
|
||||
|
||||
(defmacro defcustom-c-stylevar (name val doc &rest args)
|
||||
"Defines a style variable."
|
||||
`(progn
|
||||
(put ',name 'c-stylevar-fallback ,val)
|
||||
(defcustom ,name 'set-from-style
|
||||
,(concat doc "
|
||||
`(let ((-value- ,val))
|
||||
(c-set-stylevar-fallback ',name -value-)
|
||||
(custom-declare-variable
|
||||
',name ''set-from-style
|
||||
,(concat doc "
|
||||
|
||||
This is a style variable. Apart from the valid values described
|
||||
above, it can be set to the symbol `set-from-style'. In that case, it
|
||||
takes its value from the style system (see `c-default-style' and
|
||||
`c-styles-alist') when a CC Mode buffer is initialized. Otherwise,
|
||||
`c-style-alist') when a CC Mode buffer is initialized. Otherwise,
|
||||
the value set here overrides the style system (there is a variable
|
||||
`c-old-style-variable-behavior' that changes this, though).")
|
||||
,@(plist-put
|
||||
args ':type
|
||||
`'(radio
|
||||
(const :tag "Use style settings"
|
||||
set-from-style)
|
||||
,(let ((type (eval (plist-get args ':type))))
|
||||
(unless (consp type)
|
||||
(setq type (list type)))
|
||||
(unless (c-safe (plist-get (cdr type) ':value))
|
||||
(setcdr type (append `(:value ,val)
|
||||
(cdr type))))
|
||||
(unless (c-safe (plist-get (cdr type) ':tag))
|
||||
(setcdr type (append '(:tag "Override style settings")
|
||||
(cdr type))))
|
||||
type))))))
|
||||
,@(plist-put
|
||||
args ':type
|
||||
`(` (radio
|
||||
(const :tag "Use style settings"
|
||||
set-from-style)
|
||||
,(, (let ((type (eval (plist-get args ':type))))
|
||||
(unless (consp type)
|
||||
(setq type (list type)))
|
||||
(unless (c-safe (plist-get (cdr type) ':value))
|
||||
(setcdr type (append '(:value (, -value-))
|
||||
(cdr type))))
|
||||
(unless (c-safe (plist-get (cdr type) ':tag))
|
||||
(setcdr type (append '(:tag "Override style settings")
|
||||
(cdr type))))
|
||||
(bq-process type)))))))))
|
||||
|
||||
(defun c-valid-offset (offset)
|
||||
"Return non-nil iff OFFSET is a valid offset for a syntactic symbol.
|
||||
|
|
@ -149,11 +176,13 @@ See `c-offsets-alist'."
|
|||
(eq offset '*)
|
||||
(eq offset '/)
|
||||
(integerp offset)
|
||||
(vectorp offset)
|
||||
(functionp offset)
|
||||
(and (symbolp offset)
|
||||
(or (boundp offset)
|
||||
(fboundp offset)))
|
||||
(and (vectorp offset)
|
||||
(= (length offset) 1)
|
||||
(integerp (elt offset 0)))
|
||||
(progn
|
||||
(while (and (consp offset)
|
||||
(c-valid-offset (car offset)))
|
||||
|
|
@ -182,6 +211,18 @@ syntactic symbols in `c-offsets-alist'. Please keep it set to nil."
|
|||
:type 'boolean
|
||||
:group 'c)
|
||||
|
||||
(defcustom c-report-syntactic-errors nil
|
||||
"*If non-nil, certain syntactic errors are reported with a ding
|
||||
and a message, for example when an \"else\" is indented for which
|
||||
there's no corresponding \"if\".
|
||||
|
||||
Note however that CC Mode doesn't make any special effort to check for
|
||||
syntactic errors; that's the job of the compiler. The reason it can
|
||||
report cases like the one above is that it can't find the correct
|
||||
anchoring position to indent the line in that case."
|
||||
:type 'boolean
|
||||
:group 'c)
|
||||
|
||||
(defcustom-c-stylevar c-basic-offset 4
|
||||
"*Amount of basic offset used by + and - symbols in `c-offsets-alist'.
|
||||
Also used as the indentation step when `c-syntactic-indentation' is
|
||||
|
|
@ -206,11 +247,9 @@ When inserting a tab, actually the function stored in the variable
|
|||
Note: indentation of lines containing only comments is also controlled
|
||||
by the `c-comment-only-line-offset' variable."
|
||||
:type '(radio
|
||||
:extra-offset 8
|
||||
:format "%{C Tab Always Indent%}:\n The TAB key:\n%v"
|
||||
(const :tag "always indents, never inserts TAB" t)
|
||||
(const :tag "indents in left margin, otherwise inserts TAB" nil)
|
||||
(other :tag "inserts TAB in literals, otherwise indent" other))
|
||||
(const :tag "TAB key always indents, never inserts TAB" t)
|
||||
(const :tag "TAB key indents in left margin, otherwise inserts TAB" nil)
|
||||
(other :tag "TAB key inserts TAB in literals, otherwise indents" other))
|
||||
:group 'c)
|
||||
|
||||
(defcustom c-insert-tab-function 'insert-tab
|
||||
|
|
@ -223,17 +262,35 @@ should be inserted. Value must be a function taking no arguments."
|
|||
(defcustom c-syntactic-indentation t
|
||||
"*Whether the indentation should be controlled by the syntactic context.
|
||||
|
||||
If t, the indentation functions indents according to the syntactic
|
||||
If t, the indentation functions indent according to the syntactic
|
||||
context, using the style settings specified by `c-offsets-alist'.
|
||||
|
||||
If nil, every line is just indented to the same level as the previous
|
||||
one, and the \\[c-indent-command] command adjusts the indentation in steps
|
||||
specified by `c-basic-offset'. The indentation style have no effect
|
||||
in this mode, nor any of the indentation associated variables,
|
||||
one, and the \\[c-indent-command] command adjusts the indentation in
|
||||
steps specified by `c-basic-offset'. The indentation style has no
|
||||
effect in this mode, nor any of the indentation associated variables,
|
||||
e.g. `c-special-indent-hook'."
|
||||
:type 'boolean
|
||||
:group 'c)
|
||||
|
||||
(defcustom c-syntactic-indentation-in-macros t
|
||||
"*Enable syntactic analysis inside macros.
|
||||
If this is nil, all lines inside macro definitions are analyzed as
|
||||
`cpp-macro-cont'. Otherwise they are analyzed syntactically, just
|
||||
like normal code, and `cpp-define-intro' is used to create the
|
||||
additional indentation of the bodies of \"#define\" macros.
|
||||
|
||||
Having this enabled simplifies editing of large multiline macros, but
|
||||
it might complicate editing if CC Mode doesn't recognize the context
|
||||
of the macro content. The default context inside the macro is the
|
||||
same as the top level, so if it contains \"bare\" statements they
|
||||
might be indented wrongly, although there are special cases that
|
||||
handles this in most cases. If this problem occurs, it's usually
|
||||
countered easily by surrounding the statements by a block \(or even
|
||||
better with the \"do { ... } while \(0)\" trick)."
|
||||
:type 'boolean
|
||||
:group 'c)
|
||||
|
||||
(defcustom-c-stylevar c-comment-only-line-offset 0
|
||||
"*Extra offset for line which contains only the start of a comment.
|
||||
Can contain an integer or a cons cell of the form:
|
||||
|
|
@ -251,12 +308,90 @@ default)."
|
|||
:type '(choice (integer :tag "Non-anchored offset" 0)
|
||||
(cons :tag "Non-anchored & anchored offset"
|
||||
:value (0 . 0)
|
||||
:extra-offset 8
|
||||
(integer :tag "Non-anchored offset")
|
||||
(integer :tag "Anchored offset")))
|
||||
:group 'c)
|
||||
|
||||
(defcustom c-indent-comments-syntactically-p nil
|
||||
(defcustom-c-stylevar c-indent-comment-alist
|
||||
'((anchored-comment . (column . 0))
|
||||
(end-block . (space . 1))
|
||||
(cpp-end-block . (space . 2)))
|
||||
"*Specifies how \\[indent-for-comment] calculates the comment start column.
|
||||
This is an association list that contains entries of the form:
|
||||
|
||||
(LINE-TYPE . INDENT-SPEC)
|
||||
|
||||
LINE-TYPE specifies a type of line as described below, and INDENT-SPEC
|
||||
says what \\[indent-for-comment] should do when used on that type of line.
|
||||
|
||||
The recognized values for LINE-TYPE are:
|
||||
|
||||
empty-line -- The line is empty.
|
||||
anchored-comment -- The line contains a comment that starts in column 0.
|
||||
end-block -- The line contains a solitary block closing brace.
|
||||
cpp-end-block -- The line contains a preprocessor directive that
|
||||
closes a block, i.e. either \"#endif\" or \"#else\".
|
||||
other -- The line does not match any other entry
|
||||
currently on the list.
|
||||
|
||||
An INDENT-SPEC is a cons cell of the form:
|
||||
|
||||
(ACTION . VALUE)
|
||||
|
||||
ACTION says how \\[indent-for-comment] should align the comment, and
|
||||
VALUE is interpreted depending on ACTION. ACTION can be any of the
|
||||
following:
|
||||
|
||||
space -- Put VALUE spaces between the end of the line and the start
|
||||
of the comment.
|
||||
column -- Start the comment at the column VALUE. If the line is
|
||||
longer than that, the comment is preceded by a single
|
||||
space. If VALUE is nil, `comment-column' is used.
|
||||
align -- Align the comment with one on the previous line, if there
|
||||
is any. If the line is too long, the comment is preceded
|
||||
by a single space. If there isn't a comment start on the
|
||||
previous line, the behavior is specified by VALUE, which
|
||||
in turn is interpreted as an INDENT-SPEC.
|
||||
|
||||
If a LINE-TYPE is missing, then \\[indent-for-comment] indents the comment
|
||||
according to `comment-column'.
|
||||
|
||||
Note that a non-nil value on `c-indent-comments-syntactically-p'
|
||||
overrides this variable, so empty lines are indentented syntactically
|
||||
in that case, i.e. as if \\[c-indent-command] was used instead."
|
||||
:type
|
||||
(let ((space '(cons :tag "space"
|
||||
:format "%v"
|
||||
:value (space . 1)
|
||||
(const :format "space " space)
|
||||
(integer :format "%v")))
|
||||
(column '(cons :tag "column"
|
||||
:format "%v"
|
||||
(const :format "column " column)
|
||||
(c-integer-or-nil :format "%v"))))
|
||||
`(set ,@(mapcar
|
||||
(lambda (elt)
|
||||
`(cons :format "%v"
|
||||
(c-const-symbol :format "%v: "
|
||||
:size 20
|
||||
:value ,elt)
|
||||
(choice
|
||||
:format "%[Choice%] %v"
|
||||
:value (column . nil)
|
||||
,space
|
||||
,column
|
||||
(cons :tag "align"
|
||||
:format "%v"
|
||||
(const :format "align " align)
|
||||
(choice
|
||||
:format "%[Choice%] %v"
|
||||
:value (column . nil)
|
||||
,space
|
||||
,column)))))
|
||||
'(empty-line anchored-comment end-block cpp-end-block other))))
|
||||
:group 'c)
|
||||
|
||||
(defcustom-c-stylevar c-indent-comments-syntactically-p nil
|
||||
"*Specifies how \\[indent-for-comment] should handle comment-only lines.
|
||||
When this variable is non-nil, comment-only lines are indented
|
||||
according to syntactic analysis via `c-offsets-alist'. Otherwise, the
|
||||
|
|
@ -291,11 +426,7 @@ It's only used when a one-line block comment is broken into two or
|
|||
more lines for the first time; otherwise the appropriate prefix is
|
||||
adapted from the comment. This variable is not used for C++ line
|
||||
style comments."
|
||||
;; We need to specify a :value to prevent `defcustom-c-stylevar' from
|
||||
;; giving it an invalid value. Perhaps `defcustom-c-stylevar'
|
||||
;; should evaluate the value first?
|
||||
;; Per Abrahamsen <abraham@dina.kvl.dk> 2002-04-06.
|
||||
:type '(string :value "* ")
|
||||
:type 'string
|
||||
:group 'c)
|
||||
|
||||
(defcustom-c-stylevar c-comment-prefix-regexp
|
||||
|
|
@ -319,9 +450,17 @@ block comment starter. In other words, it should at least match
|
|||
which is sometimes inserted by CC Mode inside block comments. It
|
||||
should not match any surrounding whitespace.
|
||||
|
||||
Note that CC Mode modifies other variables from this one at mode
|
||||
initialization, so you will need to do \\[c-mode] (or whatever mode
|
||||
you're currently using) if you change it in a CC Mode buffer."
|
||||
Note that CC Mode uses this variable to set many other variables that
|
||||
handles the paragraph filling. That's done at mode initialization or
|
||||
when you switch to a style which sets this variable. Thus, if you
|
||||
change it in some other way, e.g. interactively in a CC Mode buffer,
|
||||
you will need to do \\[c-mode] (or whatever mode you're currently
|
||||
using) to reinitialize.
|
||||
|
||||
Note also that when CC Mode starts up, the other variables are
|
||||
modified before the mode hooks are run. If you change this variable
|
||||
in a mode hook, you can call `c-setup-paragraph-variables' afterwards
|
||||
to redo it."
|
||||
:type '(radio
|
||||
(regexp :tag "Regexp for all modes")
|
||||
(list
|
||||
|
|
@ -357,7 +496,6 @@ contexts are:
|
|||
cpp -- inside a preprocessor directive
|
||||
code -- anywhere else, i.e. in normal code"
|
||||
:type '(set
|
||||
:extra-offset 8
|
||||
(const :tag "String literals" string)
|
||||
(const :tag "C style block comments" c)
|
||||
(const :tag "C++ style line comments" c++)
|
||||
|
|
@ -416,7 +554,6 @@ involve auto-newline inserted newlines:
|
|||
Clean up occurs when the closing parenthesis
|
||||
is typed."
|
||||
:type '(set
|
||||
:extra-offset 8
|
||||
(const :tag "Put \"} else {\" on one line"
|
||||
brace-else-brace)
|
||||
(const :tag "Put \"} else if (...) {\" on one line"
|
||||
|
|
@ -484,7 +621,7 @@ syntactic context for the brace line."
|
|||
:size 20
|
||||
:value ,elt)
|
||||
(choice :format "%[Choice%] %v"
|
||||
:value (before after)
|
||||
:value (before after)
|
||||
(set :menu-tag "Before/after"
|
||||
:format "Newline %v brace\n"
|
||||
(const :format "%v, " before)
|
||||
|
|
@ -547,14 +684,31 @@ then no newline is inserted."
|
|||
:group 'c)
|
||||
|
||||
(defcustom-c-stylevar c-backslash-column 48
|
||||
"*Column to insert backslashes when macroizing a region."
|
||||
"*Minimum alignment column for line continuation backslashes.
|
||||
This is used by the functions that automatically insert or align the
|
||||
line continuation backslashes in multiline macros. If any line in the
|
||||
macro exceeds this column then the next tab stop from that line is
|
||||
used as alignment column instead."
|
||||
:type 'integer
|
||||
:group 'c)
|
||||
|
||||
(defcustom c-special-indent-hook nil
|
||||
"*Hook for user defined special indentation adjustments.
|
||||
This hook gets called after a line is indented by the mode."
|
||||
:type 'hook
|
||||
(defcustom-c-stylevar c-backslash-max-column 72
|
||||
"*Maximum alignment column for line continuation backslashes.
|
||||
This is used by the functions that automatically insert or align the
|
||||
line continuation backslashes in multiline macros. If any line in the
|
||||
macro exceeds this column then the backslashes for the other lines
|
||||
will be aligned at this column."
|
||||
:type 'integer
|
||||
:group 'c)
|
||||
|
||||
(defcustom c-auto-align-backslashes t
|
||||
"*Align automatically inserted line continuation backslashes.
|
||||
When line continuation backslashes are inserted automatically for line
|
||||
breaks in multiline macros, e.g. by \\[c-context-line-break], they are
|
||||
aligned with the other backslashes in the same macro if this flag is
|
||||
set. Otherwise the inserted backslashes are preceded by a single
|
||||
space."
|
||||
:type 'boolean
|
||||
:group 'c)
|
||||
|
||||
(defcustom c-backspace-function 'backward-delete-char-untabify
|
||||
|
|
@ -570,7 +724,13 @@ This hook gets called after a line is indented by the mode."
|
|||
(defcustom c-electric-pound-behavior nil
|
||||
"*List of behaviors for electric pound insertion.
|
||||
Only currently supported behavior is `alignleft'."
|
||||
:type '(set :extra-offset 8 (const alignleft))
|
||||
:type '(set (const alignleft))
|
||||
:group 'c)
|
||||
|
||||
(defcustom c-special-indent-hook nil
|
||||
"*Hook for user defined special indentation adjustments.
|
||||
This hook gets called after a line is indented by the mode."
|
||||
:type 'hook
|
||||
:group 'c)
|
||||
|
||||
(defcustom-c-stylevar c-label-minimum-indentation 1
|
||||
|
|
@ -629,18 +789,28 @@ can always override the use of `c-default-style' by making calls to
|
|||
(const :format "Other " other) (string :format "%v"))))
|
||||
:group 'c)
|
||||
|
||||
(put 'c-offsets-alist 'c-stylevar-fallback
|
||||
;; *) At the start of a statement or declaration means in more detail:
|
||||
;; At the closest preceding statement/declaration that starts at boi
|
||||
;; and doesn't have a label or comment at that position. If there's
|
||||
;; no such statement within the same block, then back up to the
|
||||
;; surrounding block or statement, add the appropriate
|
||||
;; statement-block-intro, defun-block-intro or substatement syntax
|
||||
;; symbol and continue searching.
|
||||
(c-set-stylevar-fallback 'c-offsets-alist
|
||||
'((string . c-lineup-dont-change)
|
||||
;; Relpos: Beg of previous line.
|
||||
(c . c-lineup-C-comments)
|
||||
;; Relpos: Beg of the comment.
|
||||
(defun-open . 0)
|
||||
;; Relpos: Boi at the func decl start when inside classes, bol
|
||||
;; at the func decl start when at top level.
|
||||
;; Relpos: When inside a class: Boi at the func decl start.
|
||||
;; When at top level: Bol at the func decl start. When inside
|
||||
;; a code block (only possible in Pike): At the func decl
|
||||
;; start(*).
|
||||
(defun-close . 0)
|
||||
;; Relpos: Boi at the func decl start.
|
||||
;; Relpos: At the defun block open if it's at boi, otherwise
|
||||
;; boi at the func decl start.
|
||||
(defun-block-intro . +)
|
||||
;; Relpos: Boi at the block open.
|
||||
;; Relpos: At the block open(*).
|
||||
(class-open . 0)
|
||||
;; Relpos: Boi at the class decl start.
|
||||
(class-close . 0)
|
||||
|
|
@ -649,46 +819,47 @@ can always override the use of `c-default-style' by making calls to
|
|||
;; Relpos: None for functions (inclass got the relpos then),
|
||||
;; boi at the lambda start for lambdas.
|
||||
(inline-close . 0)
|
||||
;; Relpos: For functions: Boi at the func decl start. For
|
||||
;; lambdas: At the block open if it's at boi, at the boi of the
|
||||
;; lambda start otherwise.
|
||||
;; Relpos: Inexpr functions: At the lambda block open if it's
|
||||
;; at boi, else at the statement(*) at boi of the start of the
|
||||
;; lambda construct. Otherwise: At the inline block open if
|
||||
;; it's at boi, otherwise boi at the func decl start.
|
||||
(func-decl-cont . +)
|
||||
;; Relpos: Boi at the func decl start.
|
||||
(knr-argdecl-intro . +)
|
||||
;; Relpos: Boi at the current line.
|
||||
;; Relpos: Boi at the topmost intro line.
|
||||
(knr-argdecl . 0)
|
||||
;; Relpos: Boi at the argdecl intro line.
|
||||
;; Relpos: At the beginning of the first K&R argdecl.
|
||||
(topmost-intro . 0)
|
||||
;; Relpos: Bol at the last line of previous construct.
|
||||
(topmost-intro-cont . 0)
|
||||
(topmost-intro-cont . c-lineup-topmost-intro-cont)
|
||||
;; Relpos: Boi at the topmost intro line.
|
||||
(member-init-intro . +)
|
||||
;; Relpos: Boi at the func decl arglist open.
|
||||
(member-init-cont . c-lineup-multi-inher)
|
||||
;; Relpos: Beg of the first member init.
|
||||
(inher-intro . +)
|
||||
;; Relpos: Java: Boi at the class decl start. Otherwise: Boi
|
||||
;; of current line (a bug?), unless it begins with an inher
|
||||
;; start colon, in which case boi of previous line is used.
|
||||
;; Relpos: Boi at the class decl start.
|
||||
(inher-cont . c-lineup-multi-inher)
|
||||
;; Relpos: Java: At the implements/extends keyword start.
|
||||
;; Otherwise: At the inher start colon, or boi at the class
|
||||
;; decl start if the first inherit clause hangs and it's not a
|
||||
;; func-local inherit clause (when does that occur?).
|
||||
(block-open . 0)
|
||||
;; Relpos: Inexpr statement: Boi at the preceding
|
||||
;; paren. Otherwise: None.
|
||||
;; Relpos: Inexpr statement: At the statement(*) at boi of the
|
||||
;; start of the inexpr construct. Otherwise: None.
|
||||
(block-close . 0)
|
||||
;; Relpos: At the open brace if it's at boi. Otherwise boi at
|
||||
;; the start of the statement the open brace hangs on, or boi
|
||||
;; at the preceding paren for inexpr statements.
|
||||
;; Relpos: Inexpr statement: At the inexpr block open if it's
|
||||
;; at boi, else at the statement(*) at boi of the start of the
|
||||
;; inexpr construct. Block hanging on a case/default label: At
|
||||
;; the closest preceding label that starts at boi. Otherwise:
|
||||
;; At the block open(*).
|
||||
(brace-list-open . 0)
|
||||
;; Relpos: Boi at the brace list decl start, but a starting
|
||||
;; "typedef" token is ignored.
|
||||
(brace-list-close . 0)
|
||||
;; Relpos: Boi at the brace list open.
|
||||
;; Relpos: At the brace list decl start(*).
|
||||
(brace-list-intro . +)
|
||||
;; Relpos: Boi at the brace list open.
|
||||
;; Relpos: At the brace list decl start(*).
|
||||
(brace-list-entry . 0)
|
||||
;; Relpos: At the first non-ws char after the open paren if the
|
||||
;; first token is on the same line, otherwise boi at that
|
||||
|
|
@ -696,52 +867,50 @@ can always override the use of `c-default-style' by making calls to
|
|||
(brace-entry-open . 0)
|
||||
;; Relpos: Same as brace-list-entry.
|
||||
(statement . 0)
|
||||
;; Relpos: After a ';' in the condition clause of a for
|
||||
;; Relpos: After a `;' in the condition clause of a for
|
||||
;; statement: At the first token after the starting paren.
|
||||
;; Otherwise: Boi at the start of the closest non-hanging
|
||||
;; previous statement, but after any switch label.
|
||||
;; Otherwise: At the preceding statement(*).
|
||||
(statement-cont . +)
|
||||
;; Relpos: After the first token in the condition clause of a
|
||||
;; for statement: At the first token after the starting paren.
|
||||
;; On the first line in a continued expression that starts with
|
||||
;; a stream op and there's no stream op on the previous line:
|
||||
;; Boi of previous line. Otherwise: Boi at the beginning of
|
||||
;; the statement, but after any type of label.
|
||||
;; Otherwise: At the containing statement(*).
|
||||
(statement-block-intro . +)
|
||||
;; Relpos: At the block start if it's at boi, otherwise boi at
|
||||
;; the start of the statement the open brace hangs on, or boi
|
||||
;; at the preceding paren for inexpr statements.
|
||||
;; Relpos: In inexpr statement block: At the inexpr block open
|
||||
;; if it's at boi, else at the statement(*) at boi of the start
|
||||
;; of the inexpr construct. In a block hanging on a
|
||||
;; case/default label: At the closest preceding label that
|
||||
;; starts at boi. Otherwise: At the start of the containing
|
||||
;; block(*).
|
||||
(statement-case-intro . +)
|
||||
;; Relpos: At the label keyword (always at boi).
|
||||
;; Relpos: At the case/default label(*).
|
||||
(statement-case-open . 0)
|
||||
;; Relpos: At the label keyword (always at boi).
|
||||
;; Relpos: At the case/default label(*).
|
||||
(substatement . +)
|
||||
;; Relpos: Boi at the containing statement or else clause.
|
||||
;; Relpos: At the containing statement(*).
|
||||
(substatement-open . +)
|
||||
;; Relpos: Boi at the containing statement or else clause.
|
||||
;; Relpos: At the containing statement(*).
|
||||
(substatement-label . 2)
|
||||
;; Relpos: At the containing statement(*).
|
||||
(case-label . 0)
|
||||
;; Relpos: At the switch block start if it's at boi, otherwise
|
||||
;; boi at the start of the switch condition clause.
|
||||
;; Relpos: At the start of the switch block(*).
|
||||
(access-label . -)
|
||||
;; Relpos: Eol (a bug?).
|
||||
;; Relpos: Same as inclass.
|
||||
(label . 2)
|
||||
;; Relpos: At the start of the containing block if it's at boi,
|
||||
;; otherwise boi at the start of the sexp before the block.
|
||||
;; Relpos: At the start of the containing block(*).
|
||||
(do-while-closure . 0)
|
||||
;; Relpos: Boi at the corresponding while keyword.
|
||||
;; Relpos: At the corresponding while statement(*).
|
||||
(else-clause . 0)
|
||||
;; Relpos: Boi at the corresponding if keyword.
|
||||
;; Relpos: At the corresponding if statement(*).
|
||||
(catch-clause . 0)
|
||||
;; Relpos: Boi at the previous try or catch keyword in the try
|
||||
;; statement.
|
||||
(comment-intro . c-lineup-comment)
|
||||
;; Relpos: At the previous try or catch statement clause(*).
|
||||
(comment-intro . (c-lineup-knr-region-comment c-lineup-comment))
|
||||
;; Relpos: None.
|
||||
(arglist-intro . +)
|
||||
;; Relpos: Boi at the open paren, or at the first non-ws after
|
||||
;; the open paren of the surrounding sexp, whichever is later.
|
||||
(arglist-cont . 0)
|
||||
(arglist-cont . (c-lineup-gcc-asm-reg 0))
|
||||
;; Relpos: At the first token after the open paren.
|
||||
(arglist-cont-nonempty . c-lineup-arglist)
|
||||
(arglist-cont-nonempty . (c-lineup-gcc-asm-reg c-lineup-arglist))
|
||||
;; Relpos: Boi at the open paren, or at the first non-ws after
|
||||
;; the open paren of the surrounding sexp, whichever is later.
|
||||
(arglist-close . +)
|
||||
|
|
@ -754,8 +923,10 @@ can always override the use of `c-default-style' by making calls to
|
|||
;; boi at the class decl start.
|
||||
(cpp-macro . [0])
|
||||
;; Relpos: None.
|
||||
(cpp-macro-cont . c-lineup-dont-change)
|
||||
(cpp-macro-cont . +)
|
||||
;; Relpos: At the macro start (always at boi).
|
||||
(cpp-define-intro . (c-lineup-cpp-define +))
|
||||
;; Relpos: None.
|
||||
(friend . 0)
|
||||
;; Relpos: None.
|
||||
(objc-method-intro . [0])
|
||||
|
|
@ -779,12 +950,13 @@ can always override the use of `c-default-style' by making calls to
|
|||
;; Relpos: At the namespace block open brace if it's at boi,
|
||||
;; otherwise boi at the namespace keyword.
|
||||
(template-args-cont . (c-lineup-template-args +))
|
||||
;; Relpos: Boi at the decl start.
|
||||
;; Relpos: Boi at the decl start. This might be changed; the
|
||||
;; logical position is clearly the opening '<'.
|
||||
(inlambda . c-lineup-inexpr-block)
|
||||
;; Relpos: None.
|
||||
(lambda-intro-cont . +)
|
||||
;; Relpos: Boi at the lambda start.
|
||||
(inexpr-statement . 0)
|
||||
(inexpr-statement . +)
|
||||
;; Relpos: None.
|
||||
(inexpr-class . +)
|
||||
;; Relpos: None.
|
||||
|
|
@ -844,7 +1016,7 @@ syntactic element is ignored.
|
|||
|
||||
`c-offsets-alist' is a style variable. This means that the offsets on
|
||||
this variable are normally taken from the style system in CC Mode
|
||||
\(see `c-default-style' and `c-styles-alist'). However, any offsets
|
||||
\(see `c-default-style' and `c-style-alist'). However, any offsets
|
||||
put explicitly on this list will override the style system when a CC
|
||||
Mode buffer is initialized \(there is a variable
|
||||
`c-old-style-variable-behavior' that changes this, though).
|
||||
|
|
@ -889,12 +1061,13 @@ Here is the current list of valid syntactic element symbols:
|
|||
statement-case-open -- The first line in a case block starting with brace.
|
||||
substatement -- The first line after an if/while/for/do/else.
|
||||
substatement-open -- The brace that opens a substatement block.
|
||||
case-label -- A `case' or `default' label.
|
||||
substatement-label -- Labelled line after an if/while/for/do/else.
|
||||
case-label -- A \"case\" or \"default\" label.
|
||||
access-label -- C++ private/protected/public access label.
|
||||
label -- Any ordinary label.
|
||||
do-while-closure -- The `while' that ends a do/while construct.
|
||||
else-clause -- The `else' of an if/else construct.
|
||||
catch-clause -- The `catch' or `finally' of a try/catch construct.
|
||||
do-while-closure -- The \"while\" that ends a do/while construct.
|
||||
else-clause -- The \"else\" of an if/else construct.
|
||||
catch-clause -- The \"catch\" or \"finally\" of a try/catch construct.
|
||||
comment-intro -- A line containing only a comment introduction.
|
||||
arglist-intro -- The first line in an argument list.
|
||||
arglist-cont -- Subsequent argument list lines when no
|
||||
|
|
@ -908,8 +1081,7 @@ Here is the current list of valid syntactic element symbols:
|
|||
inclass -- The construct is nested inside a class definition.
|
||||
Used together with e.g. `topmost-intro'.
|
||||
cpp-macro -- The start of a C preprocessor macro definition.
|
||||
cpp-macro-cont -- Subsequent lines in a multi-line C preprocessor
|
||||
macro definition.
|
||||
cpp-macro-cont -- Inside a multi-line C preprocessor macro definition.
|
||||
friend -- A C++ friend declaration.
|
||||
objc-method-intro -- The first line of an Objective-C method definition.
|
||||
objc-method-args-cont -- Lines continuing an Objective-C method definition.
|
||||
|
|
@ -1021,14 +1193,16 @@ Java coding styles) this can improve performance between 3 and 60
|
|||
times for core indentation functions (e.g. `c-parse-state'). For
|
||||
styles that conform to the Emacs recommendation of putting these
|
||||
braces in column zero, this can degrade performance about as much.
|
||||
This variable only has effect in XEmacs.")
|
||||
This variable only has effect in XEmacs."
|
||||
:type 'boolean
|
||||
:group 'c)
|
||||
|
||||
(defcustom c-old-style-variable-behavior nil
|
||||
(defvar c-old-style-variable-behavior nil
|
||||
"*Enables the old style variable behavior when non-nil.
|
||||
|
||||
Normally the values of the style variables will override the style
|
||||
settings specified by the variables `c-default-style' and
|
||||
`c-styles-alist'. However, in CC Mode 5.25 and earlier, it was the
|
||||
`c-style-alist'. However, in CC Mode 5.25 and earlier, it was the
|
||||
other way around, meaning that changes made to the style variables
|
||||
from e.g. Customize would not take effect unless special precautions
|
||||
were taken. That was confusing, especially for novice users.
|
||||
|
|
@ -1077,6 +1251,20 @@ Don't change this directly; call `c-set-style' instead.")
|
|||
Set from `c-comment-prefix-regexp' at mode initialization.")
|
||||
(make-variable-buffer-local 'c-current-comment-prefix)
|
||||
|
||||
(defvar c-buffer-is-cc-mode nil
|
||||
"Non-nil for all buffers with a major mode derived from CC Mode.
|
||||
Otherwise, this variable is nil. I.e. this variable is non-nil for
|
||||
`c-mode', `c++-mode', `objc-mode', `java-mode', `idl-mode',
|
||||
`pike-mode', and any other non-CC Mode mode that calls
|
||||
`c-initialize-cc-mode' (e.g. `awk-mode'). The value is the mode
|
||||
symbol itself (i.e. `c-mode' etc) of the original CC Mode mode, or
|
||||
just t if it's not known.")
|
||||
(make-variable-buffer-local 'c-buffer-is-cc-mode)
|
||||
|
||||
;; Have to make `c-buffer-is-cc-mode' permanently local so that it
|
||||
;; survives the initialization of the derived mode.
|
||||
(put 'c-buffer-is-cc-mode 'permanent-local t)
|
||||
|
||||
|
||||
;; Figure out what features this Emacs has
|
||||
;;;###autoload
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue