Commit 037558bf authored by Martin Stjernholm's avatar Martin Stjernholm
Browse files

CC Mode update (5.30.8).

parent 7c402969
2003-11-16 Martin Stjernholm <bug-cc-mode@gnu.org>
* cc-engine.el (c-guess-continued-construct,
c-guess-basic-syntax): Check a little more carefully if it's a
function declaration when an unknown construct followed by a block
is found inside a statement context. This avoids macros followed
by blocks to be taken as function declarations.
(c-guess-continued-construct): Changed the analysis of a statement
continuation with a brace open to `substatement-block', for
consistency with recognized statements.
(c-add-stmt-syntax): Don't continue to the surrounding sexp if the
start is in a position so that `c-beginning-of-statement-1' jumped
to the beginning of the same statement.
* cc-fonts.el, cc-engine.el (c-forward-<>-arglist-recur): Don't
accept binary operators in the arglist if we're in a function call
context, i.e. if `c-restricted-<>-arglists' is set. That avoids
template recognition in cases like "if (a < b || c > d)".
(c-restricted-<>-arglists): New more appropriate name for
`c-disallow-comma-in-<>-arglists'.
Accessing functions updated for the variable name change.
* cc-engine.el (c-syntactic-re-search-forward): Fix bug where the
match data could get clobbered if NOT-INSIDE-TOKEN is used.
* cc-engine.el (c-beginning-of-statement-1): Don't allow parens in
labels.
(c-backward-to-decl-anchor): Use `c-beginning-of-statement-1'
instead of duplicating parts of it. This fixes bogus label
recognition.
* cc-align.el (c-gnu-impose-minimum): Reverted to the old method
of checking the context in which to apply the minimum indentation,
so that it isn't enforced in e.g. namespace blocks.
* cc-vars.el (c-inside-block-syms): New constant used by
`c-gnu-impose-minimum'. It's defined close to `c-offsets-alist'
to somewhat reduce the risk of becoming stale.
* cc-cmds.el, cc-engine.el (c-shift-line-indentation): Moved from
cc-cmds to cc-engine to allow use from cc-align.
* cc-engine.el (c-beginning-of-inheritance-list): Cope with fully
qualified identifiers containing "::".
* cc-defs.el (c-make-keywords-re): Added kludge for bug in
`regexp-opt' in Emacs 20 and XEmacs when strings contain newlines.
* cc-vars.el (c-emacs-features): Use a space in front of the name
of the temporary buffer. That also avoids dumping problems in
XEmacs due to undo info being left around after the buffer is
killed.
* cc-engine.el (c-in-knr-argdecl): Look closer at the function
arglist to see if it's a K&R style declaration.
(c-guess-basic-syntax): CASE 5B.2: Check with `c-in-knr-argdecl'
before returning `knr-argdecl-intro'.
2003-11-16 John Wiegley <johnw@newartisans.com>
* eshell/em-ls.el (eshell-ls-file): Instead of making the size
......
......@@ -1121,35 +1121,20 @@ ACTION associated with `block-close' syntax."
'(before after)))))
(defun c-gnu-impose-minimum ()
"Imposes a minimum indentation for lines inside a top-level construct.
"Imposes a minimum indentation for lines inside code blocks.
The variable `c-label-minimum-indentation' specifies the minimum
indentation amount."
;; Don't adjust macro or comment-only lines.
(unless (or (assq 'cpp-macro c-syntactic-context)
(assq 'comment-intro c-syntactic-context))
(let ((paren-state (save-excursion
;; Get the parenthesis state, but skip past
;; an initial closing paren on the line since
;; the close brace of a block shouldn't be
;; considered to be inside the block.
(back-to-indentation)
(when (looking-at "\\s\)")
(forward-char))
(c-parse-state))))
;; Search for an enclosing brace on paren-state.
(while (and paren-state
(not (and (integer-or-marker-p (car paren-state))
(eq (char-after (car paren-state)) ?{))))
(setq paren-state (cdr paren-state)))
(when paren-state
(save-excursion
(back-to-indentation)
(if (zerop (current-column))
(insert-char ?\ c-label-minimum-indentation t)))))))
(when (and (not
;; Don't adjust macro or comment-only lines.
(or (assq 'cpp-macro c-syntactic-context)
(assq 'comment-intro c-syntactic-context)))
(c-intersect-lists c-inside-block-syms c-syntactic-context)
(save-excursion
(back-to-indentation)
(< (current-column) c-label-minimum-indentation)))
(c-shift-line-indentation (- c-label-minimum-indentation
(current-indentation)))))
;; Useful for c-hanging-semi&comma-criteria
......
......@@ -54,37 +54,6 @@
(defvar c-fix-backslashes t)
(defun c-shift-line-indentation (shift-amt)
;; This function does not do any hidden buffer changes.
(let ((pos (- (point-max) (point)))
(c-macro-start c-macro-start)
tmp-char-inserted)
(if (zerop shift-amt)
nil
(when (and (c-query-and-set-macro-start)
(looking-at "[ \t]*\\\\$")
(save-excursion
(skip-chars-backward " \t")
(bolp)))
(insert ?x)
(backward-char)
(setq tmp-char-inserted t))
(unwind-protect
(let ((col (current-indentation)))
(delete-region (c-point 'bol) (c-point 'boi))
(beginning-of-line)
(indent-to (+ col shift-amt)))
(when tmp-char-inserted
(delete-char 1))))
;; If initial point was within line's indentation and we're not on
;; a line with a line continuation in a macro, position after the
;; indentation. Else stay at same point in text.
(if (and (< (point) (c-point 'boi))
(not tmp-char-inserted))
(back-to-indentation)
(if (> (- (point-max) pos) (point))
(goto-char (- (point-max) pos))))))
(defun c-indent-line (&optional syntax quiet ignore-point-pos)
"Indent the current line according to the syntactic context,
if `c-syntactic-indentation' is non-nil. Optional SYNTAX is the
......
......@@ -105,7 +105,7 @@
;;; Variables also used at compile time.
(defconst c-version "5.30.7"
(defconst c-version "5.30.8"
"CC Mode version number.")
(defconst c-version-sym (intern c-version))
......@@ -1001,8 +1001,8 @@ This function does not do any hidden buffer changes."
(defun c-make-keywords-re (adorn list &optional mode)
"Make a regexp that matches all the strings the list.
Duplicates in the list are removed. The regexp may contain zero or
more submatch expressions.
Duplicates in the list are removed. The resulting regexp may contain
zero or more submatch expressions.
If ADORN is non-nil there will be at least one submatch and the first
matches the whole keyword, and the regexp will also not match a prefix
......@@ -1010,6 +1010,7 @@ of any identifier. Adorned regexps cannot be appended. The language
variable `c-nonsymbol-key' is used to make the adornment. The
optional MODE specifies the language to get it in. The default is the
current language (taken from `c-buffer-is-cc-mode')."
(let (unique)
(dolist (elt list)
(unless (member elt unique)
......@@ -1017,6 +1018,27 @@ current language (taken from `c-buffer-is-cc-mode')."
(setq list unique))
(if list
(let ((re (c-regexp-opt list)))
;; Emacs < 21 and XEmacs (all versions so far) has a buggy
;; regexp-opt that doesn't always cope with strings containing
;; newlines. This kludge doesn't handle shy parens correctly
;; so we can't advice regexp-opt directly with it.
(let (fail-list)
(while list
(and (string-match "\n" (car list)) ; To speed it up a little.
(not (string-match (concat "\\`\\(" re "\\)\\'")
(car list)))
(setq fail-list (cons (car list) fail-list)))
(setq list (cdr list)))
(when fail-list
(setq re (concat re
"\\|"
(mapconcat 'regexp-quote
(sort fail-list
(lambda (a b)
(> (length a) (length b))))
"\\|")))))
;; Add our own grouping parenthesis around re instead of
;; passing adorn to `regexp-opt', since in XEmacs it makes the
;; top level grouping "shy".
......@@ -1026,10 +1048,12 @@ current language (taken from `c-buffer-is-cc-mode')."
(c-get-lang-constant 'c-nonsymbol-key nil mode)
"\\|$\\)")
re))
;; Produce a regexp that matches nothing.
(if adorn
"\\(\\<\\>\\)"
"\\<\\>")))
(put 'c-make-keywords-re 'lisp-indent-function 1)
......
This diff is collapsed.
......@@ -894,7 +894,7 @@ casts and declarations are fontified. Used on level 2 and higher."
(save-restriction
(let (start-pos
c-disallow-comma-in-<>-arglists
c-restricted-<>-arglists
;; Nonzero if the `c-decl-prefix-re' match is in an arglist context,
;; as opposed to a statement-level context. The major difference is
;; that "," works as declaration delimiter in an arglist context,
......@@ -1050,11 +1050,11 @@ casts and declarations are fontified. Used on level 2 and higher."
;; If we're in a normal arglist context we don't want to
;; recognize commas in nested angle bracket arglists since
;; those commas could be part of our own arglist.
c-disallow-comma-in-<>-arglists
c-restricted-<>-arglists
(and c-recognize-<>-arglists
(eq arglist-type 'other)))
(when (and c-disallow-comma-in-<>-arglists
(when (and c-restricted-<>-arglists
(/= arglist-match ?,))
;; We're standing at the start of a normal arglist so remove any
;; angle bracket arglists containing commas that's been
......
......@@ -878,12 +878,11 @@ This hook gets called after a line is indented by the mode."
:group 'c)
(defcustom-c-stylevar c-label-minimum-indentation 1
"*Minimum indentation for lines inside of top-level constructs.
"*Minimum indentation for lines inside code blocks.
This variable typically only affects code using the `gnu' style, which
mandates a minimum of one space in front of every line inside
top-level constructs. Specifically, the function
`c-gnu-impose-minimum' on your `c-special-indent-hook' is what
enforces this."
mandates a minimum of one space in front of every line inside code
blocks. Specifically, the function `c-gnu-impose-minimum' on your
`c-special-indent-hook' is what enforces this."
:type 'integer
:group 'c)
......@@ -1271,6 +1270,14 @@ Here is the current list of valid syntactic element symbols:
(get 'c-offsets-alist 'c-stylevar-fallback)))
:group 'c)
;; The syntactic symbols that can occur inside code blocks. Used by
;; `c-gnu-impose-minimum'.
(defconst c-inside-block-syms
'(defun-block-intro block-open block-close statement statement-cont
statement-block-intro statement-case-intro statement-case-open
substatement substatement-open substatement-label case-label label
do-while-closure else-clause catch-clause inlambda))
(defcustom c-style-variables-are-local-p t
"*Whether style variables should be buffer local by default.
If non-nil, then all indentation style related variables will be made
......@@ -1575,7 +1582,7 @@ Set from `c-comment-prefix-regexp' at mode initialization.")
'1-bit)
list)))
(let ((buf (generate-new-buffer "test"))
(let ((buf (generate-new-buffer " test"))
parse-sexp-lookup-properties
parse-sexp-ignore-comments
lookup-syntax-properties)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment