Commit 2a15eb73 authored by Martin Stjernholm's avatar Martin Stjernholm
Browse files

Updated CC Mode to 5.30.9.

parent 7c3225c3
2004-08-11 Martin Stjernholm <bug-cc-mode@gnu.org>
CC Mode update to 5.30.9:
* progmodes/cc-defs.el, progmodes/cc-vars.el (c-emacs-features):
Moved from cc-vars to cc-defs for dependency reasons. Fixed the
POSIX char class test to check that it works in
`skip-chars-(forward|backward)' too.
* progmodes/cc-align.el (c-lineup-arglist): Fixed bug when the
first argument starts with a special brace list.
* progmodes/cc-engine.el (c-forward-type): Fixed promotion bug
when `c-opt-type-concat-key' is used (i.e. in Pike).
* progmodes/cc-engine.el (c-looking-at-special-brace-list): Fixed
bug when the inner char pair doesn't have paren syntax, i.e. "(<
>)".
* progmodes/cc-align.el (c-lineup-multi-inher): Made it syntactic
whitespace safe.
* progmodes/cc-engine.el (c-guess-basic-syntax): Fixed anchor
position for `arglist-intro', `arglist-cont-nonempty' and
`arglist-close' when there are two arglist open parens on the same
line and there's nothing in front of the first.
* progmodes/cc-fonts.el (c-basic-matchers-before): Fixed font
locking of qualified names in Java, which previously could fontify
common indexing expressions in many cases. The standard Java
naming conventions are used to tell them apart.
* progmodes/cc-align.el (c-lineup-whitesmith-in-block): Fixed
inconsistency wrt opening parens on the first line inside a paren
block.
* progmodes/cc-defs.el (c-langs-are-parametric): Must be known at
compile time for the sake of `c-major-mode-is'.
(c-mode-is-new-awk-p): Made it a macro to delay expansion of
`c-major-mode-is' in the event that this is used inside a
`c-lang-defconst'.
* progmodes/cc-defs.el (c-major-mode-is): Fixed expansion inside
`c-lang-defconst' so that it works better with fallback languages.
* progmodes/cc-defs.el (c-add-language): Fixed a typo that caused
it to fail to record the base mode.
* progmodes/cc-engine.el (c-syntactic-re-search-forward): Fixed
bug so that it doesn't go past the closing paren when PAREN-LEVEL
is used. Reordered the syntax checks to get more efficient
skipping in some situations.
* progmodes/cc-cmds.el (c-electric-brace): Don't trip up on a line
continuation which might precede the newly inserted '{'.
* progmodes/cc-engine.el (c-syntactic-re-search-forward): Fixed
cases where it could loop indefinitely.
* progmodes/cc-fonts.el (c-font-lock-declarators): Handle array
size specs correctly. Only fontify identifiers in front of '('
with as functions - don't accept any paren char. Tightened up
initializer skipping to stop before function and class blocks.
* progmodes/cc-engine.el (c-beginning-of-decl-1): Fixed bug where
the point could be left directly after an open paren when finding
the beginning of the first decl in the block.
* progmodes/cc-engine.el (c-parse-state): Don't use the syntax
table when filtering out legitimate open parens to be recorded.
This could cause cache inconsistencies when e.g.
`c++-template-syntax-table' was temporarily in use.
* progmodes/cc-engine.el (c-on-identifier,
c-simple-skip-symbol-backward): Small fix for handling "-"
correctly in `skip-chars-backward'. Affected the operator lfun
syntax in Pike.
* progmodes/cc-engine.el (c-invalidate-sws-region-after): Fixed
bug that could cause an error from `after-change-functions' when
the changed region is at bob.
2004-08-11 Alan Mackenzie <bug-cc-mode@gnu.org>
CC Mode update to 5.30.9:
* progmodes/cc-cmds.el, progmodes/cc-vars.el: Amend doc(-strings)
to say that <TAB> doesn't insert WS into a CPP line.
(c-indent-command, c-tab-always-indent): Amend doc strings.
* progmodes/cc-styles.el, progmodes/cc-engine.el: Add in two
checks for user errors, thus eliminating cryptic and unhelpful
Emacs error messages. (1) Check the arg to `c-set-style' is a
string. (2) Check that settings to `c-offsets-alist' are not
spuriously quoted.
* progmodes/cc-cmds.el: (c-electric-brace): don't delete a comment
which precedes the newly inserted `{'.
2004-08-10 Michael Albinus <michael.albinus@gmx.de>
Sync with Tramp 2.0.44.
......
......@@ -121,7 +121,7 @@ Works with: arglist-cont-nonempty, arglist-close."
;; like "({".
(when c-special-brace-lists
(let ((special-list (c-looking-at-special-brace-list)))
(when special-list
(when (and special-list (< (car (car special-list)) (point)))
(goto-char (+ (car (car special-list)) 2)))))
(let ((savepos (point))
......@@ -380,9 +380,7 @@ Works with: inher-cont, member-init-cont."
(back-to-indentation)
(let* ((eol (c-point 'eol))
(here (point))
(char-after-ip (progn
(skip-chars-forward " \t")
(char-after))))
(char-after-ip (char-after)))
(if (cdr langelem) (goto-char (cdr langelem)))
;; This kludge is necessary to support both inher-cont and
......@@ -392,13 +390,12 @@ Works with: inher-cont, member-init-cont."
(backward-char)
(c-backward-syntactic-ws))
(skip-chars-forward "^:" eol)
(if (eq char-after-ip ?,)
(skip-chars-forward " \t" eol)
(skip-chars-forward " \t:" eol))
(if (or (eolp)
(looking-at c-comment-start-regexp))
(c-forward-syntactic-ws here))
(c-syntactic-re-search-forward ":" eol 'move)
(if (looking-at c-syntactic-eol)
(c-forward-syntactic-ws here)
(if (eq char-after-ip ?,)
(backward-char)
(skip-chars-forward " \t" eol)))
(if (< (point) here)
(vector (current-column)))
)))
......@@ -952,11 +949,17 @@ Works with: defun-close, defun-block-intro, block-close,
brace-list-close, brace-list-intro, statement-block-intro and all in*
symbols, e.g. inclass and inextern-lang."
(save-excursion
(goto-char (cdr langelem))
(back-to-indentation)
(if (eq (char-syntax (char-after)) ?\()
0
c-basic-offset)))
(+ (progn
(back-to-indentation)
(if (eq (char-syntax (char-after)) ?\()
c-basic-offset
0))
(progn
(goto-char (cdr langelem))
(back-to-indentation)
(if (eq (char-syntax (char-after)) ?\()
0
c-basic-offset)))))
(defun c-lineup-cpp-define (langelem)
"Line up macro continuation lines according to the indentation of
......
......@@ -479,7 +479,11 @@ This function does various newline cleanups based on the value of
;; end up before it.
(setq delete-temp-newline
(cons (save-excursion
(c-backward-syntactic-ws)
(end-of-line 0)
(if (eq (char-before) ?\\)
;; Ignore a line continuation.
(backward-char))
(skip-chars-backward " \t")
(copy-marker (point) t))
(point-marker))))
(unwind-protect
......@@ -1971,8 +1975,7 @@ If `c-tab-always-indent' is t, always just indent the current line.
If nil, indent the current line only if point is at the left margin or
in the line's indentation; otherwise insert some whitespace[*]. If
other than nil or t, then some whitespace[*] is inserted only within
literals (comments and strings) and inside preprocessor directives,
but the line is always reindented.
literals (comments and strings), but the line is always reindented.
If `c-syntactic-indentation' is t, indentation is done according to
the syntactic context. A numeric argument, regardless of its value,
......
......@@ -48,7 +48,6 @@
;; Silence the compiler.
(cc-bytecomp-defvar c-enable-xemacs-performance-kludge-p) ; In cc-vars.el
(cc-bytecomp-defvar c-emacs-features) ; 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
......@@ -105,7 +104,7 @@
;;; Variables also used at compile time.
(defconst c-version "5.30.8"
(defconst c-version "5.30.9"
"CC Mode version number.")
(defconst c-version-sym (intern c-version))
......@@ -620,20 +619,36 @@ This function does not do any hidden buffer changes."
(eq (char-before) ?\\)))
(backward-char))))
(eval-and-compile
(defvar c-langs-are-parametric nil))
(defmacro c-major-mode-is (mode)
"Return non-nil if the current CC Mode major mode is MODE.
MODE is either a mode symbol or a list of mode symbols.
This function does not do any hidden buffer changes."
(if (eq (car-safe mode) 'quote)
(let ((mode (eval mode)))
(if (listp mode)
`(memq c-buffer-is-cc-mode ',mode)
`(eq c-buffer-is-cc-mode ',mode)))
`(let ((mode ,mode))
(if (listp mode)
(memq c-buffer-is-cc-mode mode)
(eq c-buffer-is-cc-mode mode)))))
(if c-langs-are-parametric
;; Inside a `c-lang-defconst'.
`(c-lang-major-mode-is ,mode)
(if (eq (car-safe mode) 'quote)
(let ((mode (eval mode)))
(if (listp mode)
`(memq c-buffer-is-cc-mode ',mode)
`(eq c-buffer-is-cc-mode ',mode)))
`(let ((mode ,mode))
(if (listp mode)
(memq c-buffer-is-cc-mode mode)
(eq c-buffer-is-cc-mode mode))))))
(defmacro c-mode-is-new-awk-p ()
;; Is the current mode the "new" awk mode? It is important for
;; (e.g.) the cc-engine functions do distinguish between the old and
;; new awk-modes.
'(and (c-major-mode-is 'awk-mode)
(memq 'syntax-properties c-emacs-features)))
(defmacro c-parse-sexp-lookup-properties ()
;; Return the value of the variable that says whether the
......@@ -968,13 +983,6 @@ the value of the variable with that name.
This function does not do any hidden buffer changes."
(symbol-value (c-mode-symbol suffix)))
(defsubst c-mode-is-new-awk-p ()
;; Is the current mode the "new" awk mode? It is important for
;; (e.g.) the cc-engine functions do distinguish between the old and
;; new awk-modes.
(and (c-major-mode-is 'awk-mode)
(memq 'syntax-properties c-emacs-features)))
(defsubst c-got-face-at (pos faces)
"Return non-nil if position POS in the current buffer has any of the
faces in the list FACES.
......@@ -1056,12 +1064,156 @@ current language (taken from `c-buffer-is-cc-mode')."
(put 'c-make-keywords-re 'lisp-indent-function 1)
;; Figure out what features this Emacs has
(cc-bytecomp-defvar open-paren-in-column-0-is-defun-start)
(defconst c-emacs-features
(let (list)
(if (boundp 'infodock-version)
;; I've no idea what this actually is, but it's legacy. /mast
(setq list (cons 'infodock list)))
;; XEmacs 19 and beyond use 8-bit modify-syntax-entry flags.
;; Emacs 19 uses a 1-bit flag. We will have to set up our
;; syntax tables differently to handle this.
(let ((table (copy-syntax-table))
entry)
(modify-syntax-entry ?a ". 12345678" table)
(cond
;; XEmacs 19, and beyond Emacs 19.34
((arrayp table)
(setq entry (aref table ?a))
;; In Emacs, table entries are cons cells
(if (consp entry) (setq entry (car entry))))
;; XEmacs 20
((fboundp 'get-char-table) (setq entry (get-char-table ?a table)))
;; before and including Emacs 19.34
((and (fboundp 'char-table-p)
(char-table-p table))
(setq entry (car (char-table-range table [?a]))))
;; incompatible
(t (error "CC Mode is incompatible with this version of Emacs")))
(setq list (cons (if (= (logand (lsh entry -16) 255) 255)
'8-bit
'1-bit)
list)))
(let ((buf (generate-new-buffer " test"))
parse-sexp-lookup-properties
parse-sexp-ignore-comments
lookup-syntax-properties)
(save-excursion
(set-buffer buf)
(set-syntax-table (make-syntax-table))
;; For some reason we have to set some of these after the
;; buffer has been made current. (Specifically,
;; `parse-sexp-ignore-comments' in Emacs 21.)
(setq parse-sexp-lookup-properties t
parse-sexp-ignore-comments t
lookup-syntax-properties t)
;; Find out if the `syntax-table' text property works.
(modify-syntax-entry ?< ".")
(modify-syntax-entry ?> ".")
(insert "<()>")
(c-mark-<-as-paren 1)
(c-mark->-as-paren 4)
(goto-char 1)
(c-forward-sexp)
(if (= (point) 5)
(setq list (cons 'syntax-properties list)))
;; Find out if generic comment delimiters work.
(c-safe
(modify-syntax-entry ?x "!")
(if (string-match "\\s!" "x")
(setq list (cons 'gen-comment-delim list))))
;; Find out if generic string delimiters work.
(c-safe
(modify-syntax-entry ?x "|")
(if (string-match "\\s|" "x")
(setq list (cons 'gen-string-delim list))))
;; See if POSIX char classes work.
(when (and (string-match "[[:alpha:]]" "a")
;; All versions of Emacs 21 so far haven't fixed
;; char classes in `skip-chars-forward' and
;; `skip-chars-backward'.
(progn
(delete-region (point-min) (point-max))
(insert "foo123")
(skip-chars-backward "[:alnum:]")
(bobp))
(= (skip-chars-forward "[:alpha:]") 3))
(setq list (cons 'posix-char-classes list)))
;; See if `open-paren-in-column-0-is-defun-start' exists and
;; isn't buggy.
(when (boundp 'open-paren-in-column-0-is-defun-start)
(let ((open-paren-in-column-0-is-defun-start nil)
(parse-sexp-ignore-comments t))
(delete-region (point-min) (point-max))
(set-syntax-table (make-syntax-table))
(modify-syntax-entry ?\' "\"")
(cond
;; XEmacs. Afaik this is currently an Emacs-only
;; feature, but it's good to be prepared.
((memq '8-bit list)
(modify-syntax-entry ?/ ". 1456")
(modify-syntax-entry ?* ". 23"))
;; Emacs
((memq '1-bit list)
(modify-syntax-entry ?/ ". 124b")
(modify-syntax-entry ?* ". 23")))
(modify-syntax-entry ?\n "> b")
(insert "/* '\n () */")
(backward-sexp)
(if (bobp)
(setq list (cons 'col-0-paren list)))))
(set-buffer-modified-p nil))
(kill-buffer buf))
;; See if `parse-partial-sexp' returns the eighth element.
(when (c-safe (>= (length (save-excursion (parse-partial-sexp 1 1))) 10))
(setq list (cons 'pps-extended-state list)))
;;(message "c-emacs-features: %S" list)
list)
"A list of certain features in the (X)Emacs you are using.
There are many flavors of Emacs out there, each with different
features supporting those needed by CC Mode. The following values
might be present:
'8-bit 8 bit syntax entry flags (XEmacs style).
'1-bit 1 bit syntax entry flags (Emacs style).
'syntax-properties It works to override the syntax for specific characters
in the buffer with the 'syntax-table property.
'gen-comment-delim Generic comment delimiters work
(i.e. the syntax class `!').
'gen-string-delim Generic string delimiters work
(i.e. the syntax class `|').
'pps-extended-state `parse-partial-sexp' returns a list with at least 10
elements, i.e. it contains the position of the
start of the last comment or string.
'posix-char-classes The regexp engine understands POSIX character classes.
'col-0-paren It's possible to turn off the ad-hoc rule that a paren
in column zero is the start of a defun.
'infodock This is Infodock (based on XEmacs).
'8-bit and '1-bit are mutually exclusive.")
;;; Some helper constants.
;; If the regexp engine supports POSIX char classes (e.g. Emacs 21)
;; then we can use them to handle extended charsets correctly.
(if (string-match "[[:alpha:]]" "a") ; Can't use c-emacs-features here.
;; If the regexp engine supports POSIX char classes then we can use
;; them to handle extended charsets correctly.
(if (memq 'posix-char-classes c-emacs-features)
(progn
(defconst c-alpha "[:alpha:]")
(defconst c-alnum "[:alnum:]")
......@@ -1127,8 +1279,8 @@ system."
(error "The mode name symbol `%s' must end with \"-mode\"" mode))
(put mode 'c-mode-prefix (match-string 1 (symbol-name mode)))
(unless (get base-mode 'c-mode-prefix)
(error "Unknown base mode `%s'" base-mode)
(put mode 'c-fallback-mode base-mode)))
(error "Unknown base mode `%s'" base-mode))
(put mode 'c-fallback-mode base-mode))
(defvar c-lang-constants (make-vector 151 0))
;; This obarray is a cache to keep track of the language constants
......@@ -1144,7 +1296,6 @@ system."
;; various other symbols, but those don't have any variable bindings.
(defvar c-lang-const-expansion nil)
(defvar c-langs-are-parametric nil)
(defsubst c-get-current-file ()
;; Return the base name of the current file.
......@@ -1585,6 +1736,22 @@ This macro does not do any hidden buffer changes."
c-lang-constants)))
(defun c-lang-major-mode-is (mode)
;; `c-major-mode-is' expands to a call to this function inside
;; `c-lang-defconst'. Here we also match the mode(s) against any
;; fallback modes for the one in `c-buffer-is-cc-mode', so that
;; e.g. (c-major-mode-is 'c++-mode) is true in a derived language
;; that has c++-mode as base mode.
(unless (listp mode)
(setq mode (list mode)))
(let (match (buf-mode c-buffer-is-cc-mode))
(while (if (memq buf-mode mode)
(progn
(setq match t)
nil)
(setq buf-mode (get buf-mode 'c-fallback-mode))))
match))
(cc-provide 'cc-defs)
......
......@@ -1270,7 +1270,7 @@ This function does not do any hidden buffer changes."
(when (and (= beg end)
(get-text-property beg 'c-in-sws)
(not (bobp))
(> beg (point-min))
(get-text-property (1- beg) 'c-in-sws))
;; Ensure that an `c-in-sws' range gets broken. Note that it isn't
;; safe to keep a range that was continuous before the change. E.g:
......@@ -1906,7 +1906,7 @@ This function does not do any hidden buffer changes."
(if last-pos
;; Prepare to loop, but record the open paren only if it's
;; outside a macro or within the same macro as point, and
;; if it is a "real" open paren and not some character
;; if it is a legitimate open paren and not some character
;; that got an open paren syntax-table property.
(progn
(setq pos last-pos)
......@@ -1914,7 +1914,11 @@ This function does not do any hidden buffer changes."
(save-excursion
(goto-char last-pos)
(not (c-beginning-of-macro))))
(= (char-syntax (char-before last-pos)) ?\())
;; Check for known types of parens that we want
;; to record. The syntax table is not to be
;; trusted here since the caller might be using
;; e.g. `c++-template-syntax-table'.
(memq (char-before last-pos) '(?{ ?\( ?\[)))
(setq c-state-cache (cons (1- last-pos) c-state-cache))))
(if (setq last-pos (c-up-list-forward pos))
......@@ -2124,7 +2128,7 @@ This function does not do any hidden buffer changes."
(when (c-major-mode-is 'pike-mode)
;; Handle the `<operator> syntax in Pike.
(let ((pos (point)))
(skip-chars-backward "!%&*+\\-/<=>^|~[]()")
(skip-chars-backward "-!%&*+/<=>^|~[]()")
(and (if (< (skip-chars-backward "`") 0)
t
(goto-char pos)
......@@ -2144,7 +2148,7 @@ This function does not do any hidden buffer changes."
(and (c-major-mode-is 'pike-mode)
;; Handle the `<operator> syntax in Pike.
(let ((pos (point)))
(if (and (< (skip-chars-backward "!%&*+\\-/<=>^|~[]()") 0)
(if (and (< (skip-chars-backward "-!%&*+/<=>^|~[]()") 0)
(< (skip-chars-backward "`") 0)
(looking-at c-symbol-key)
(>= (match-end 0) pos))
......@@ -2384,8 +2388,11 @@ outside any comment, macro or string literal, or else the content of
that region is taken as syntactically significant text.
If PAREN-LEVEL is non-nil, an additional restriction is added to
ignore matches in nested paren sexps, and the search will also not go
outside the current paren sexp.
ignore matches in nested paren sexps. The search will also not go
outside the current list sexp, which has the effect that if the point
should be moved to BOUND when no match is found \(i.e. NOERROR is
neither nil nor t), then it will be at the closing paren if the end of
the current list sexp is encountered first.
If NOT-INSIDE-TOKEN is non-nil, matches in the middle of tokens are
ignored. Things like multicharacter operators and special symbols
......@@ -2401,11 +2408,15 @@ subexpression is never tested before the starting position, so it
might be a good idea to include \\=\\= as a match alternative in it.
Optimization note: Matches might be missed if the \"look behind\"
subexpression should match the end of nonwhite syntactic whitespace,
subexpression can match the end of nonwhite syntactic whitespace,
i.e. the end of comments or cpp directives. This since the function
skips over such things before resuming the search. It's also not safe
to assume that the \"look behind\" subexpression never can match
syntactic whitespace."
skips over such things before resuming the search. It's on the other
hand not safe to assume that the \"look behind\" subexpression never
matches syntactic whitespace.
Bug: Unbalanced parens inside cpp directives are currently not handled
correctly \(i.e. they don't get ignored as they should) when
PAREN-LEVEL is set."
(or bound (setq bound (point-max)))
(if paren-level (setq paren-level -1))
......@@ -2413,53 +2424,55 @@ syntactic whitespace."
;;(message "c-syntactic-re-search-forward %s %s %S" (point) bound regexp)
(let ((start (point))
(pos (point))
tmp
;; Start position for the last search.
search-pos
;; The `parse-partial-sexp' state between the start position
;; and the point.
state
;; The current position after the last state update. The next
;; `parse-partial-sexp' continues from here.
(state-pos (point))
;; The position at which to check the state and the state
;; there. This is separate from `state-pos' since we might
;; need to back up before doing the next search round.
check-pos check-state
;; Last position known to end a token.
(last-token-end-pos (point-min))
match-pos found state check-pos check-state tmp)
;; Set when a valid match is found.
found)
(condition-case err
(while
(and
(re-search-forward regexp bound noerror)
(progn
(setq search-pos (point))
(re-search-forward regexp bound noerror))
(progn
(setq match-pos (point)
state (parse-partial-sexp
pos (match-beginning 0) paren-level nil state)
pos (point))
(setq state (parse-partial-sexp
state-pos (match-beginning 0) paren-level nil state)
state-pos (point))
(if (setq check-pos (and lookbehind-submatch
(or (not paren-level)
(>= (car state) 0))
(match-end lookbehind-submatch)))
(setq check-state (parse-partial-sexp
pos check-pos paren-level nil state))
(setq check-pos pos
state-pos check-pos paren-level nil state))
(setq check-pos state-pos
check-state state))
;; If we got a look behind subexpression and get an
;; insignificant match in something that isn't
;; NOTE: If we got a look behind subexpression and get
;; an insignificant match in something that isn't
;; syntactic whitespace (i.e. strings or in nested
;; parentheses), then we can never skip more than a
;; single character from the match position before
;; continuing the search. That since the look behind
;; subexpression might match the end of the
;; insignificant region.
;; single character from the match start position
;; (i.e. `state-pos' here) before continuing the
;; search. That since the look behind subexpression
;; might match the end of the insignificant region in
;; the next search.
(cond
((setq tmp (elt check-state 3))
;; Match inside a string.
(if (or lookbehind-submatch
(not (integerp tmp)))
(goto-char (min (1+ pos) bound))
;; Skip to the end of the string before continuing.
(let ((ender (make-string 1 tmp)) (continue t))
(while (if (search-forward ender bound noerror)
(progn
(setq state (parse-partial-sexp
pos (point) nil nil state)
pos (point))
(elt state 3))
(setq continue nil)))
continue)))
((elt check-state 7)