diff options
author | Alan Mackenzie <[email protected]> | 2006-02-24 15:33:02 +0000 |
---|---|---|
committer | Alan Mackenzie <[email protected]> | 2006-02-24 15:33:02 +0000 |
commit | cb694ab73063cc92342daf96d009cdc6d086bc0b (patch) | |
tree | f60c5467a7d18135fc252a6702fcbaf38c2f980d /lisp/progmodes/cc-engine.el | |
parent | 0d566910540fa519c48f90455bdecd4565cea948 (diff) |
cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
cc-defs.el, cc-engine.el, cc-fonts.el, cc-langs.el, cc-menus.el,
cc-mode.el, cc-styles.el, cc-subword.el, cc-vars.el: Add 2006 to the
copyright statement.
cc-awk.el: (c-awk-after-change): Protect the match data with
save-match-data. It was being corrupted when Font Lock was not enabled.
(ii): Fix a typo.
cc-cmds.el, cc-mode.el, cc-engine.el (c-update-modeline): Concatenate the
minor mode indicators directly onto mode-name, removing
c-submode-indicators. Sometimes, c-s-i got separated from the mode name
on the mode line.
cc-cmds.el, cc-mode.el: Rename c-hungry-backspace to
c-hungry-delete-backwards, at the request of RMS. Leave the old name as
an alias.
cc-cmds.el (c-electric-brace, c-electric-semi&comma, c-electric-colon):
Correct doc-strings: "/ln" -> "/la".
cc-cmds.el (c-electric-brace): Fix clean-up brace-else-brace (error due
to mbeg, mend being undefined).
cc-defs.el (c-version): Update to 5.31.3.
cc-defs.el: [Supersedes patch V1.38]: (top level): Check for a buggy
font-lock-compile-keywords ONLY in XEmacs. GNU Emacs 22 now has a check
which would throw an error here.
cc-engine.el (c-beginning-of-statement-1): Clarify doc-string and
comments. Distinguish real labels ("case 1:" or "foo:") from non-labels
("public:").
cc-engine.el (c-after-change-check-<>-operators): Remove save-match-data,
reversing change for V1.45. save-match-data is now in c-after-change.
cc-engine.el (c-forward-objc-directive): Replace c-forward-token-2 with
crude coding; c-f-t-2 doesn't move over a token at EOB. Objc Mode was
hanging after typing, e.g., "@implementation".
cc-langs.el (c-filter-ops): Made it available at runtime too to work when
`c-make-init-lang-vars-fun' needs to evaluate from source.
cc-langs.el (c-make-init-lang-vars-fun): Improved the error message when
there's an evaluation error to show whether it's loaded from source or
not.
(c-mode-menu): Add menu items for Electric Mode and Subword Mode.
cc-mode.el (c-after-change): Protect the match data with save-match-data.
It was getting corrupted by c-after-change-check-<>-operators.
cc-mode.el: File Local variables: Solve the problem where both `mode' and
c-file-offsets are specified: `mode' will overwrite c-f-o's settings:
(c-remove-any-local-eval-or-mode-variables): new function.
(c-postprocess-file-styles): call the above new function, within
c-tentative-buffer-change, to splat `mode' and `eval' before the second
hack-local-variables.
Diffstat (limited to 'lisp/progmodes/cc-engine.el')
-rw-r--r-- | lisp/progmodes/cc-engine.el | 112 |
1 files changed, 63 insertions, 49 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 548fc74d96..32c82eb1c1 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -1,7 +1,7 @@ ;;; cc-engine.el --- core syntax guessing engine for CC mode -;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 -;; Free Software Foundation, Inc. +;; Copyright (C) 1985,1987,1992-2003, 2004, 2005, 2006 Free Software Foundation, +;; Inc. ;; Authors: 1998- Martin Stjernholm ;; 1992-1999 Barry A. Warsaw @@ -179,8 +179,8 @@ (make-variable-buffer-local 'c-auto-newline) ;; Included in the mode line to indicate the active submodes. -(defvar c-submode-indicators nil) -(make-variable-buffer-local 'c-submode-indicators) +;; (defvar c-submode-indicators nil) +;; (make-variable-buffer-local 'c-submode-indicators) (defun c-calculate-state (arg prevstate) ;; Calculate the new state of PREVSTATE, t or nil, based on arg. If @@ -525,14 +525,15 @@ also stop at a continuation clause. Labels are treated as part of the following statements if IGNORE-LABELS is non-nil. (FIXME: Doesn't work if we stop at a known -statement start keyword.) +statement start keyword.) Otherwise, each label is treated as a +separate statement. -Macros are ignored unless point is within one, in which case the -content of the macro is treated as normal code. Aside from any normal -statement starts found in it, stop at the first token of the content -in the macro, i.e. the expression of an \"#if\" or the start of the -definition in a \"#define\". Also stop at start of macros before -leaving them. +Macros are ignored \(i.e. skipped over) unless point is within one, in +which case the content of the macro is treated as normal code. Aside +from any normal statement starts found in it, stop at the first token +of the content in the macro, i.e. the expression of an \"#if\" or the +start of the definition in a \"#define\". Also stop at start of +macros before leaving them. Return 'label if stopped at a label, 'same if stopped at the beginning of the current statement, 'up if stepped to a containing statement, @@ -547,8 +548,9 @@ position if that is less ('same is returned in this case). NOERROR turns off error logging to `c-parsing-error'. -Normally only ';' is considered to delimit statements, but if -COMMA-DELIM is non-nil then ',' is treated likewise. +Normally only ';' and virtual semicolons are considered to delimit +statements, but if COMMA-DELIM is non-nil then ',' is treated +as a delimiter too. Note that this function might do hidden buffer changes. See the comment at the start of cc-engine.el for more info." @@ -883,6 +885,7 @@ comment at the start of cc-engine.el for more info." ;; barriers in this round. (sexp-loop-end-pos pos)) + ;; The following while goes back one sexp per iteration. (while (progn (unless (c-safe (c-backward-sexp) t) @@ -954,7 +957,7 @@ comment at the start of cc-engine.el for more info." ;; Like a C "continue". Analyze the next sexp. (throw 'loop t))) - sexp-loop-continue-pos) + sexp-loop-continue-pos) ; End of "go back a sexp" loop. (goto-char sexp-loop-continue-pos) (setq sexp-loop-end-pos sexp-loop-continue-pos sexp-loop-continue-pos nil)))) @@ -969,17 +972,26 @@ comment at the start of cc-engine.el for more info." ;; Handle labels. (unless (eq ignore-labels t) (when (numberp c-maybe-labelp) - ;; `c-crosses-statement-barrier-p' has found a - ;; colon, so we might be in a label now. - (if after-labels-pos - (if (not last-label-pos) - (setq last-label-pos (or tok start))) - (setq after-labels-pos (or tok start))) - (setq c-maybe-labelp t - label-good-pos nil)) - - (when (and (not label-good-pos) - (looking-at c-nonlabel-token-key)) + ;; `c-crosses-statement-barrier-p' has found a colon, so we + ;; might be in a label now. Have we got a real label + ;; (including a case label) or something like C++'s "public:"? + (if (or (not (looking-at c-nonlabel-token-key)) ; proper label + (save-excursion ; e.g. "case 'a':" ? + (and (c-safe (c-backward-sexp) t) + (looking-at "\\<case\\>")))) ; FIXME!!! this is + ; wrong for AWK. 2006/1/14. + (progn + (if after-labels-pos ; Have we already encountered a label? + (if (not last-label-pos) + (setq last-label-pos (or tok start))) + (setq after-labels-pos (or tok start))) + (setq c-maybe-labelp t + label-good-pos nil)) + (setq c-maybe-labelp nil))) ; bogus "label" + + (when (and (not label-good-pos) ; i.e. no invalid "label"'s yet + ; been found. + (looking-at c-nonlabel-token-key)) ; e.g. "while :" ;; We're in a potential label and it's the first ;; time we've found something that isn't allowed in ;; one. @@ -3993,36 +4005,35 @@ comment at the start of cc-engine.el for more info." ;; ;; This function might do hidden buffer changes. - (save-match-data - (save-excursion + (save-excursion + (goto-char beg) + (when (or (looking-at "[<>]") + (< (skip-chars-backward "<>") 0)) + (goto-char beg) + (c-beginning-of-current-token) + (when (and (< (point) beg) + (looking-at c-<>-multichar-token-regexp) + (< beg (setq beg (match-end 0)))) + (while (progn (skip-chars-forward "^<>" beg) + (< (point) beg)) + (c-clear-char-property (point) 'syntax-table) + (forward-char)))) + + (when (< beg end) + (goto-char end) (when (or (looking-at "[<>]") (< (skip-chars-backward "<>") 0)) - (goto-char beg) + (goto-char end) (c-beginning-of-current-token) - (when (and (< (point) beg) + (when (and (< (point) end) (looking-at c-<>-multichar-token-regexp) - (< beg (setq beg (match-end 0)))) - (while (progn (skip-chars-forward "^<>" beg) - (< (point) beg)) + (< end (setq end (match-end 0)))) + (while (progn (skip-chars-forward "^<>" end) + (< (point) end)) (c-clear-char-property (point) 'syntax-table) - (forward-char)))) - - (when (< beg end) - (goto-char end) - (when (or (looking-at "[<>]") - (< (skip-chars-backward "<>") 0)) - - (goto-char end) - (c-beginning-of-current-token) - (when (and (< (point) end) - (looking-at c-<>-multichar-token-regexp) - (< end (setq end (match-end 0)))) - (while (progn (skip-chars-forward "^<>" end) - (< (point) end)) - (c-clear-char-property (point) 'syntax-table) - (forward-char)))))))) + (forward-char))))))) ;; Dynamically bound variable that instructs `c-forward-type' to also ;; treat possible types (i.e. those that it normally returns 'maybe or @@ -5991,7 +6002,10 @@ y ;; True if there's a suffix match outside the outermost ;; Handle the name of the class itself. (progn - (c-forward-token-2) +; (c-forward-token-2) ; 2006/1/13 This doesn't move if the token's +; at EOB. + (goto-char (match-end 0)) + (c-skip-ws-forward) (c-forward-type)) (catch 'break |