annotate lisp/progmodes/cc-engine.el @ 99688:0dc2933fc901

(compilation-start-hook): New hook. (compilation-start): Run it on the compilation process.
author Sam Steingold <sds@gnu.org>
date Tue, 18 Nov 2008 14:14:37 +0000
parents c6c533f20c51
children a9dc0e7c3f2b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1 ;;; cc-engine.el --- core syntax guessing engine for CC mode
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2
74372
cf3e4c6cd4c3 Fix Copyright format.
Glenn Morris <rgm@gnu.org>
parents: 69140
diff changeset
3 ;; Copyright (C) 1985, 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
79717
a1342e6e097a Add 2008 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 79408
diff changeset
4 ;; 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
75347
e3694f1cb928 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 75315
diff changeset
5 ;; Free Software Foundation, Inc.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6
75307
4389f67a231f Add my name.
Alan Mackenzie <acm@muc.de>
parents: 75027
diff changeset
7 ;; Authors: 2001- Alan Mackenzie
4389f67a231f Add my name.
Alan Mackenzie <acm@muc.de>
parents: 75027
diff changeset
8 ;; 1998- Martin Stjernholm
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9 ;; 1992-1999 Barry A. Warsaw
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; 1987 Dave Detlefs and Stewart Clamen
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; 1985 Richard M. Stallman
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
12 ;; Maintainer: bug-cc-mode@gnu.org
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; Created: 22-Apr-1997 (split from cc-mode.el)
20142
e66d1eef0bff (c-guess-basic-syntax):
Karl Heuer <kwzh@gnu.org>
parents: 20139
diff changeset
14 ;; Version: See cc-mode.el
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; Keywords: c languages oop
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; This file is part of GNU Emacs.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18
94673
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
19 ;; GNU Emacs is free software: you can redistribute it and/or modify
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; it under the terms of the GNU General Public License as published by
94673
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
21 ;; the Free Software Foundation, either version 3 of the License, or
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
22 ;; (at your option) any later version.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; GNU Emacs is distributed in the hope that it will be useful,
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;; GNU General Public License for more details.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
28
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
29 ;; You should have received a copy of the GNU General Public License
94673
52b7a8c22af5 Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents: 93975
diff changeset
30 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31
38422
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 36920
diff changeset
32 ;;; Commentary:
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 36920
diff changeset
33
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
34 ;; The functions which have docstring documentation can be considered
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
35 ;; part of an API which other packages can use in CC Mode buffers.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
36 ;; Otoh, undocumented functions and functions with the documentation
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
37 ;; in comments are considered purely internal and can change semantics
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
38 ;; or even disappear in the future.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
39 ;;
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
40 ;; (This policy applies to CC Mode as a whole, not just this file. It
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
41 ;; probably also applies to many other Emacs packages, but here it's
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
42 ;; clearly spelled out.)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
43
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
44 ;; Hidden buffer changes
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
45 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
46 ;; Various functions in CC Mode use text properties for caching and
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
47 ;; syntactic markup purposes, and those of them that might modify such
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
48 ;; properties but still don't modify the buffer in a visible way are
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
49 ;; said to do "hidden buffer changes". They should be used within
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
50 ;; `c-save-buffer-state' or a similar function that saves and restores
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
51 ;; buffer modifiedness, disables buffer change hooks, etc.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
52 ;;
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
53 ;; Interactive functions are assumed to not do hidden buffer changes,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
54 ;; except in the specific parts of them that do real changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
55 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
56 ;; Lineup functions are assumed to do hidden buffer changes. They
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
57 ;; must not do real changes, though.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
58 ;;
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
59 ;; All other functions that do hidden buffer changes have that noted
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
60 ;; in their doc string or comment.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
61 ;;
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
62 ;; The intention with this system is to avoid wrapping every leaf
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
63 ;; function that do hidden buffer changes inside
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
64 ;; `c-save-buffer-state'. It should be used as near the top of the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
65 ;; interactive functions as possible.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
66 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
67 ;; Functions called during font locking are allowed to do hidden
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
68 ;; buffer changes since the font-lock package run them in a context
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
69 ;; similar to `c-save-buffer-state' (in fact, that function is heavily
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
70 ;; inspired by `save-buffer-state' in the font-lock package).
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
71
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
72 ;; Use of text properties
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
73 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
74 ;; CC Mode uses several text properties internally to mark up various
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
75 ;; positions, e.g. to improve speed and to eliminate glitches in
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
76 ;; interactive refontification.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
77 ;;
51829
d508ffa43505 2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51714
diff changeset
78 ;; Note: This doc is for internal use only. Other packages should not
d508ffa43505 2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51714
diff changeset
79 ;; assume that these text properties are used as described here.
d508ffa43505 2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51714
diff changeset
80 ;;
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
81 ;; 'syntax-table
80157
e67a400370f5 Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents: 79953
diff changeset
82 ;; Used to modify the syntax of some characters. It is used to
e67a400370f5 Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents: 79953
diff changeset
83 ;; mark the "<" and ">" of angle bracket parens with paren syntax, and
e67a400370f5 Set of changes so that "obtrusive" syntactic elements in a
Alan Mackenzie <acm@muc.de>
parents: 79953
diff changeset
84 ;; to "hide" obtrusive characters in preprocessor lines.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
85 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
86 ;; This property is used on single characters and is therefore
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
87 ;; always treated as front and rear nonsticky (or start and end open
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
88 ;; in XEmacs vocabulary). It's therefore installed on
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
89 ;; `text-property-default-nonsticky' if that variable exists (Emacs
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
90 ;; >= 21).
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
91 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
92 ;; 'c-is-sws and 'c-in-sws
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
93 ;; Used by `c-forward-syntactic-ws' and `c-backward-syntactic-ws' to
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
94 ;; speed them up. See the comment blurb before `c-put-is-sws'
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
95 ;; below for further details.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
96 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
97 ;; 'c-type
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
98 ;; This property is used on single characters to mark positions with
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
99 ;; special syntactic relevance of various sorts. Its primary use is
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
100 ;; to avoid glitches when multiline constructs are refontified
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
101 ;; interactively (on font lock decoration level 3). It's cleared in
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
102 ;; a region before it's fontified and is then put on relevant chars
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
103 ;; in that region as they are encountered during the fontification.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
104 ;; The value specifies the kind of position:
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
105 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
106 ;; 'c-decl-arg-start
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
107 ;; Put on the last char of the token preceding each declaration
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
108 ;; inside a declaration style arglist (typically in a function
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
109 ;; prototype).
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
110 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
111 ;; 'c-decl-end
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
112 ;; Put on the last char of the token preceding a declaration.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
113 ;; This is used in cases where declaration boundaries can't be
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
114 ;; recognized simply by looking for a token like ";" or "}".
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
115 ;; `c-type-decl-end-used' must be set if this is used (see also
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
116 ;; `c-find-decl-spots').
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
117 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
118 ;; 'c-<>-arg-sep
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
119 ;; Put on the commas that separate arguments in angle bracket
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
120 ;; arglists like C++ template arglists.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
121 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
122 ;; 'c-decl-id-start and 'c-decl-type-start
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
123 ;; Put on the last char of the token preceding each declarator
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
124 ;; in the declarator list of a declaration. They are also used
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
125 ;; between the identifiers cases like enum declarations.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
126 ;; 'c-decl-type-start is used when the declarators are types,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
127 ;; 'c-decl-id-start otherwise.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
128 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
129 ;; 'c-awk-NL-prop
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
130 ;; Used in AWK mode to mark the various kinds of newlines. See
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
131 ;; cc-awk.el.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
132
38422
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 36920
diff changeset
133 ;;; Code:
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 36920
diff changeset
134
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
135 (eval-when-compile
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
136 (let ((load-path
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
137 (if (and (boundp 'byte-compile-dest-file)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
138 (stringp byte-compile-dest-file))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
139 (cons (file-name-directory byte-compile-dest-file) load-path)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
140 load-path)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
141 (load "cc-bytecomp" nil t)))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
142
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
143 (cc-require 'cc-defs)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
144 (cc-require-when-compile 'cc-langs)
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
145 (cc-require 'cc-vars)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
146
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
147 ;; Silence the compiler.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
148 (cc-bytecomp-defun buffer-syntactic-context) ; XEmacs
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
149
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
151 ;; Make declarations for all the `c-lang-defvar' variables in cc-langs.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
152
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
153 (defmacro c-declare-lang-variables ()
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
154 `(progn
51888
b5a29d6f2851 (c-declare-lang-variables): Don't use mapcan.
Richard M. Stallman <rms@gnu.org>
parents: 51829
diff changeset
155 ,@(apply 'nconc
b5a29d6f2851 (c-declare-lang-variables): Don't use mapcan.
Richard M. Stallman <rms@gnu.org>
parents: 51829
diff changeset
156 (mapcar (lambda (init)
b5a29d6f2851 (c-declare-lang-variables): Don't use mapcan.
Richard M. Stallman <rms@gnu.org>
parents: 51829
diff changeset
157 `(,(if (elt init 2)
b5a29d6f2851 (c-declare-lang-variables): Don't use mapcan.
Richard M. Stallman <rms@gnu.org>
parents: 51829
diff changeset
158 `(defvar ,(car init) nil ,(elt init 2))
b5a29d6f2851 (c-declare-lang-variables): Don't use mapcan.
Richard M. Stallman <rms@gnu.org>
parents: 51829
diff changeset
159 `(defvar ,(car init) nil))
b5a29d6f2851 (c-declare-lang-variables): Don't use mapcan.
Richard M. Stallman <rms@gnu.org>
parents: 51829
diff changeset
160 (make-variable-buffer-local ',(car init))))
b5a29d6f2851 (c-declare-lang-variables): Don't use mapcan.
Richard M. Stallman <rms@gnu.org>
parents: 51829
diff changeset
161 (cdr c-lang-variable-inits)))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
162 (c-declare-lang-variables)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
163
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
164
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
165 ;;; Internal state variables.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
166
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
167 ;; Internal state of hungry delete key feature
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
168 (defvar c-hungry-delete-key nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
169 (make-variable-buffer-local 'c-hungry-delete-key)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
170
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
171 ;; The electric flag (toggled by `c-toggle-electric-state').
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
172 ;; If t, electric actions (like automatic reindentation, and (if
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
173 ;; c-auto-newline is also set) auto newlining) will happen when an electric
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
174 ;; key like `{' is pressed (or an electric keyword like `else').
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
175 (defvar c-electric-flag t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
176 (make-variable-buffer-local 'c-electric-flag)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
177
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
178 ;; Internal state of auto newline feature.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
179 (defvar c-auto-newline nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
180 (make-variable-buffer-local 'c-auto-newline)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
181
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
182 ;; Included in the mode line to indicate the active submodes.
69140
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
183 ;; (defvar c-submode-indicators nil)
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
184 ;; (make-variable-buffer-local 'c-submode-indicators)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
185
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
186 (defun c-calculate-state (arg prevstate)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
187 ;; Calculate the new state of PREVSTATE, t or nil, based on arg. If
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
188 ;; arg is nil or zero, toggle the state. If arg is negative, turn
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
189 ;; the state off, and if arg is positive, turn the state on
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
190 (if (or (not arg)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
191 (zerop (setq arg (prefix-numeric-value arg))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
192 (not prevstate)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
193 (> arg 0)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
194
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
195 ;; Dynamically bound cache for `c-in-literal'.
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
196 (defvar c-in-literal-cache t)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
197
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
198
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
199 ;; Basic handling of preprocessor directives.
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
200
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
201 ;; This is a dynamically bound cache used together with
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
202 ;; `c-query-macro-start' and `c-query-and-set-macro-start'. It only
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
203 ;; works as long as point doesn't cross a macro boundary.
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
204 (defvar c-macro-start 'unknown)
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
205
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
206 (defsubst c-query-and-set-macro-start ()
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
207 (if (symbolp c-macro-start)
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
208 (setq c-macro-start (save-excursion
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
209 (c-save-buffer-state ()
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
210 (and (c-beginning-of-macro)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
211 (point)))))
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
212 c-macro-start))
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
213
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
214 (defsubst c-query-macro-start ()
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
215 (if (symbolp c-macro-start)
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
216 (save-excursion
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
217 (c-save-buffer-state ()
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
218 (and (c-beginning-of-macro)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
219 (point))))
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
220 c-macro-start))
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
221
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
222 (defun c-beginning-of-macro (&optional lim)
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
223 "Go to the beginning of a preprocessor directive.
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
224 Leave point at the beginning of the directive and return t if in one,
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
225 otherwise return nil and leave point unchanged.
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
226
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
227 Note that this function might do hidden buffer changes. See the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
228 comment at the start of cc-engine.el for more info."
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
229 (when c-opt-cpp-prefix
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
230 (let ((here (point)))
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
231 (save-restriction
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
232 (if lim (narrow-to-region lim (point-max)))
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
233 (beginning-of-line)
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
234 (while (eq (char-before (1- (point))) ?\\)
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
235 (forward-line -1))
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
236 (back-to-indentation)
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
237 (if (and (<= (point) here)
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
238 (looking-at c-opt-cpp-start))
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
239 t
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
240 (goto-char here)
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
241 nil)))))
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
242
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
243 (defun c-end-of-macro ()
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
244 "Go to the end of a preprocessor directive.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
245 More accurately, move the point to the end of the closest following
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
246 line that doesn't end with a line continuation backslash - no check is
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
247 done that the point is inside a cpp directive to begin with.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
248
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
249 Note that this function might do hidden buffer changes. See the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
250 comment at the start of cc-engine.el for more info."
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
251 (while (progn
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
252 (end-of-line)
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
253 (when (and (eq (char-before) ?\\)
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
254 (not (eobp)))
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
255 (forward-char)
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
256 t))))
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
257
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
258 (defun c-forward-over-cpp-define-id ()
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
259 ;; Assuming point is at the "#" that introduces a preprocessor
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
260 ;; directive, it's moved forward to the end of the identifier which is
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
261 ;; "#define"d (or whatever c-opt-cpp-macro-define specifies). Non-nil
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
262 ;; is returned in this case, in all other cases nil is returned and
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
263 ;; point isn't moved.
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
264 ;;
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
265 ;; This function might do hidden buffer changes.
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
266 (when (and c-opt-cpp-macro-define-id
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
267 (looking-at c-opt-cpp-macro-define-id))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
268 (goto-char (match-end 0))))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
269
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
270 (defun c-forward-to-cpp-define-body ()
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
271 ;; Assuming point is at the "#" that introduces a preprocessor
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
272 ;; directive, it's moved forward to the start of the definition body
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
273 ;; if it's a "#define" (or whatever c-opt-cpp-macro-define
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
274 ;; specifies). Non-nil is returned in this case, in all other cases
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
275 ;; nil is returned and point isn't moved.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
276 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
277 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
278 (when (and c-opt-cpp-macro-define-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
279 (looking-at c-opt-cpp-macro-define-start)
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
280 (not (= (match-end 0) (c-point 'eol))))
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
281 (goto-char (match-end 0))))
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
282
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
283
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
284 ;;; Basic utility functions.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
285
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
286 (defun c-syntactic-content (from to paren-level)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
287 ;; Return the given region as a string where all syntactic
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
288 ;; whitespace is removed or, where necessary, replaced with a single
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
289 ;; space. If PAREN-LEVEL is given then all parens in the region are
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
290 ;; collapsed to "()", "[]" etc.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
291 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
292 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
293
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
294 (save-excursion
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
295 (save-restriction
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
296 (narrow-to-region from to)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
297 (goto-char from)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
298 (let* ((parts (list nil)) (tail parts) pos in-paren)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
299
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
300 (while (re-search-forward c-syntactic-ws-start to t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
301 (goto-char (setq pos (match-beginning 0)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
302 (c-forward-syntactic-ws)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
303 (if (= (point) pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
304 (forward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
305
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
306 (when paren-level
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
307 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
308 (setq in-paren (= (car (parse-partial-sexp from pos 1)) 1)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
309 pos (point))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
310
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
311 (if (and (> pos from)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
312 (< (point) to)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
313 (looking-at "\\w\\|\\s_")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
314 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
315 (goto-char (1- pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
316 (looking-at "\\w\\|\\s_")))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
317 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
318 (setcdr tail (list (buffer-substring-no-properties from pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
319 " "))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
320 (setq tail (cddr tail)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
321 (setcdr tail (list (buffer-substring-no-properties from pos)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
322 (setq tail (cdr tail)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
323
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
324 (when in-paren
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
325 (when (= (car (parse-partial-sexp pos to -1)) -1)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
326 (setcdr tail (list (buffer-substring-no-properties
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
327 (1- (point)) (point))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
328 (setq tail (cdr tail))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
329
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
330 (setq from (point))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
331
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
332 (setcdr tail (list (buffer-substring-no-properties from to)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
333 (apply 'concat (cdr parts))))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
334
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
335 (defun c-shift-line-indentation (shift-amt)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
336 ;; Shift the indentation of the current line with the specified
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
337 ;; amount (positive inwards). The buffer is modified only if
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
338 ;; SHIFT-AMT isn't equal to zero.
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
339 (let ((pos (- (point-max) (point)))
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
340 (c-macro-start c-macro-start)
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
341 tmp-char-inserted)
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
342 (if (zerop shift-amt)
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
343 nil
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
344 ;; If we're on an empty line inside a macro, we take the point
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
345 ;; to be at the current indentation and shift it to the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
346 ;; appropriate column. This way we don't treat the extra
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
347 ;; whitespace out to the line continuation as indentation.
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
348 (when (and (c-query-and-set-macro-start)
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
349 (looking-at "[ \t]*\\\\$")
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
350 (save-excursion
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
351 (skip-chars-backward " \t")
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
352 (bolp)))
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
353 (insert ?x)
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
354 (backward-char)
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
355 (setq tmp-char-inserted t))
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
356 (unwind-protect
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
357 (let ((col (current-indentation)))
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
358 (delete-region (c-point 'bol) (c-point 'boi))
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
359 (beginning-of-line)
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
360 (indent-to (+ col shift-amt)))
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
361 (when tmp-char-inserted
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
362 (delete-char 1))))
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
363 ;; If initial point was within line's indentation and we're not on
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
364 ;; a line with a line continuation in a macro, position after the
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
365 ;; indentation. Else stay at same point in text.
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
366 (if (and (< (point) (c-point 'boi))
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
367 (not tmp-char-inserted))
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
368 (back-to-indentation)
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
369 (if (> (- (point-max) pos) (point))
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
370 (goto-char (- (point-max) pos))))))
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
371
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
372 (defsubst c-keyword-sym (keyword)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
373 ;; Return non-nil if the string KEYWORD is a known keyword. More
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
374 ;; precisely, the value is the symbol for the keyword in
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
375 ;; `c-keywords-obarray'.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
376 (intern-soft keyword c-keywords-obarray))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
377
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
378 (defsubst c-keyword-member (keyword-sym lang-constant)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
379 ;; Return non-nil if the symbol KEYWORD-SYM, as returned by
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
380 ;; `c-keyword-sym', is a member of LANG-CONSTANT, which is the name
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
381 ;; of a language constant that ends with "-kwds". If KEYWORD-SYM is
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
382 ;; nil then the result is nil.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
383 (get keyword-sym lang-constant))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
384
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
385 ;; String syntax chars, suitable for skip-syntax-(forward|backward).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
386 (defconst c-string-syntax (if (memq 'gen-string-delim c-emacs-features)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
387 "\"|"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
388 "\""))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
389
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
390 ;; Regexp matching string limit syntax.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
391 (defconst c-string-limit-regexp (if (memq 'gen-string-delim c-emacs-features)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
392 "\\s\"\\|\\s|"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
393 "\\s\""))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
394
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
395 ;; Regexp matching WS followed by string limit syntax.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
396 (defconst c-ws*-string-limit-regexp
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
397 (concat "[ \t]*\\(" c-string-limit-regexp "\\)"))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
398
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
399 ;; Holds formatted error strings for the few cases where parse errors
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
400 ;; are reported.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
401 (defvar c-parsing-error nil)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
402 (make-variable-buffer-local 'c-parsing-error)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
403
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
404 (defun c-echo-parsing-error (&optional quiet)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
405 (when (and c-report-syntactic-errors c-parsing-error (not quiet))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
406 (c-benign-error "%s" c-parsing-error))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
407 c-parsing-error)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
408
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
409 ;; Faces given to comments and string literals. This is used in some
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
410 ;; situations to speed up recognition; it isn't mandatory that font
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
411 ;; locking is in use. This variable is extended with the face in
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
412 ;; `c-doc-face-name' when fontification is activated in cc-fonts.el.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
413 (defvar c-literal-faces
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
414 (append '(font-lock-comment-face font-lock-string-face)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
415 (when (facep 'font-lock-comment-delimiter-face)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
416 ;; New in Emacs 22.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
417 '(font-lock-comment-delimiter-face))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
418
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
419 (defsubst c-put-c-type-property (pos value)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
420 ;; Put a c-type property with the given value at POS.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
421 (c-put-char-property pos 'c-type value))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
422
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
423 (defun c-clear-c-type-property (from to value)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
424 ;; Remove all occurences of the c-type property that has the given
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
425 ;; value in the region between FROM and TO. VALUE is assumed to not
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
426 ;; be nil.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
427 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
428 ;; Note: This assumes that c-type is put on single chars only; it's
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
429 ;; very inefficient if matching properties cover large regions.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
430 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
431 (goto-char from)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
432 (while (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
433 (when (eq (get-text-property (point) 'c-type) value)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
434 (c-clear-char-property (point) 'c-type))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
435 (goto-char (next-single-property-change (point) 'c-type nil to))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
436 (< (point) to)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
437
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
438
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
439 ;; Some debug tools to visualize various special positions. This
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
440 ;; debug code isn't as portable as the rest of CC Mode.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
441
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
442 (cc-bytecomp-defun overlays-in)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
443 (cc-bytecomp-defun overlay-get)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
444 (cc-bytecomp-defun overlay-start)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
445 (cc-bytecomp-defun overlay-end)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
446 (cc-bytecomp-defun delete-overlay)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
447 (cc-bytecomp-defun overlay-put)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
448 (cc-bytecomp-defun make-overlay)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
449
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
450 (defun c-debug-add-face (beg end face)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
451 (c-save-buffer-state ((overlays (overlays-in beg end)) overlay)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
452 (while overlays
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
453 (setq overlay (car overlays)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
454 overlays (cdr overlays))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
455 (when (eq (overlay-get overlay 'face) face)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
456 (setq beg (min beg (overlay-start overlay))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
457 end (max end (overlay-end overlay)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
458 (delete-overlay overlay)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
459 (overlay-put (make-overlay beg end) 'face face)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
460
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
461 (defun c-debug-remove-face (beg end face)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
462 (c-save-buffer-state ((overlays (overlays-in beg end)) overlay
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
463 (ol-beg beg) (ol-end end))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
464 (while overlays
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
465 (setq overlay (car overlays)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
466 overlays (cdr overlays))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
467 (when (eq (overlay-get overlay 'face) face)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
468 (setq ol-beg (min ol-beg (overlay-start overlay))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
469 ol-end (max ol-end (overlay-end overlay)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
470 (delete-overlay overlay)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
471 (when (< ol-beg beg)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
472 (overlay-put (make-overlay ol-beg beg) 'face face))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
473 (when (> ol-end end)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
474 (overlay-put (make-overlay end ol-end) 'face face))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
475
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
476
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
477 ;; `c-beginning-of-statement-1' and accompanying stuff.
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
478
18844
6b269c4ad2eb (c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 18720
diff changeset
479 ;; KLUDGE ALERT: c-maybe-labelp is used to pass information between
6b269c4ad2eb (c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 18720
diff changeset
480 ;; c-crosses-statement-barrier-p and c-beginning-of-statement-1. A
6b269c4ad2eb (c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 18720
diff changeset
481 ;; better way should be implemented, but this will at least shut up
6b269c4ad2eb (c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 18720
diff changeset
482 ;; the byte compiler.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
483 (defvar c-maybe-labelp)
18844
6b269c4ad2eb (c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 18720
diff changeset
484
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
485 ;; New awk-compatible version of c-beginning-of-statement-1, ACM 2002/6/22
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
486
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
487 ;; Macros used internally in c-beginning-of-statement-1 for the
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
488 ;; automaton actions.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
489 (defmacro c-bos-push-state ()
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
490 '(setq stack (cons (cons state saved-pos)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
491 stack)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
492 (defmacro c-bos-pop-state (&optional do-if-done)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
493 `(if (setq state (car (car stack))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
494 saved-pos (cdr (car stack))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
495 stack (cdr stack))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
496 t
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
497 ,do-if-done
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
498 (throw 'loop nil)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
499 (defmacro c-bos-pop-state-and-retry ()
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
500 '(throw 'loop (setq state (car (car stack))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
501 saved-pos (cdr (car stack))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
502 ;; Throw nil if stack is empty, else throw non-nil.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
503 stack (cdr stack))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
504 (defmacro c-bos-save-pos ()
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
505 '(setq saved-pos (vector pos tok ptok pptok)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
506 (defmacro c-bos-restore-pos ()
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
507 '(unless (eq (elt saved-pos 0) start)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
508 (setq pos (elt saved-pos 0)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
509 tok (elt saved-pos 1)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
510 ptok (elt saved-pos 2)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
511 pptok (elt saved-pos 3))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
512 (goto-char pos)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
513 (setq sym nil)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
514 (defmacro c-bos-save-error-info (missing got)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
515 `(setq saved-pos (vector pos ,missing ,got)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
516 (defmacro c-bos-report-error ()
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
517 '(unless noerror
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
518 (setq c-parsing-error
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
519 (format "No matching `%s' found for `%s' on line %d"
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
520 (elt saved-pos 1)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
521 (elt saved-pos 2)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
522 (1+ (count-lines (point-min)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
523 (c-point 'bol (elt saved-pos 0))))))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
524
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
525 (defun c-beginning-of-statement-1 (&optional lim ignore-labels
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
526 noerror comma-delim)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
527 "Move to the start of the current statement or declaration, or to
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
528 the previous one if already at the beginning of one. Only
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
529 statements/declarations on the same level are considered, i.e. don't
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
530 move into or out of sexps (not even normal expression parentheses).
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
531
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
532 If point is already at the earliest statment within braces or parens,
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
533 this function doesn't move back into any whitespace preceding it; it
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
534 returns 'same in this case.
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
535
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
536 Stop at statement continuation tokens like \"else\", \"catch\",
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
537 \"finally\" and the \"while\" in \"do ... while\" if the start point
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
538 is within the continuation. If starting at such a token, move to the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
539 corresponding statement start. If at the beginning of a statement,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
540 move to the closest containing statement if there is any. This might
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
541 also stop at a continuation clause.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
542
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
543 Labels are treated as part of the following statements if
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
544 IGNORE-LABELS is non-nil. (FIXME: Doesn't work if we stop at a known
69140
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
545 statement start keyword.) Otherwise, each label is treated as a
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
546 separate statement.
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
547
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
548 Macros are ignored \(i.e. skipped over) unless point is within one, in
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
549 which case the content of the macro is treated as normal code. Aside
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
550 from any normal statement starts found in it, stop at the first token
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
551 of the content in the macro, i.e. the expression of an \"#if\" or the
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
552 start of the definition in a \"#define\". Also stop at start of
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
553 macros before leaving them.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
554
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
555 Return:
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
556 'label if stopped at a label;
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
557 'same if stopped at the beginning of the current statement;
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
558 'up if stepped to a containing statement;
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
559 'previous if stepped to a preceding statement;
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
560 'beginning if stepped from a statement continuation clause to
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
561 its start clause; or
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
562 'macro if stepped to a macro start.
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
563 Note that 'same and not 'label is returned if stopped at the same
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
564 label without crossing the colon character.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
565
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
566 LIM may be given to limit the search. If the search hits the limit,
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
567 point will be left at the closest following token, or at the start
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
568 position if that is less ('same is returned in this case).
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
569
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
570 NOERROR turns off error logging to `c-parsing-error'.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
571
69140
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
572 Normally only ';' and virtual semicolons are considered to delimit
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
573 statements, but if COMMA-DELIM is non-nil then ',' is treated
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
574 as a delimiter too.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
575
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
576 Note that this function might do hidden buffer changes. See the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
577 comment at the start of cc-engine.el for more info."
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
578
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
579 ;; The bulk of this function is a pushdown automaton that looks at statement
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
580 ;; boundaries and the tokens (such as "while") in c-opt-block-stmt-key. Its
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
581 ;; purpose is to keep track of nested statements, ensuring that such
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
582 ;; statments are skipped over in their entirety (somewhat akin to what C-M-p
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
583 ;; does with nested braces/brackets/parentheses).
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
584 ;;
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
585 ;; Note: The position of a boundary is the following token.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
586 ;;
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
587 ;; Beginning with the current token (the one following point), move back one
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
588 ;; sexp at a time (where a sexp is, more or less, either a token or the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
589 ;; entire contents of a brace/bracket/paren pair). Each time a statement
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
590 ;; boundary is crossed or a "while"-like token is found, update the state of
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
591 ;; the PDA. Stop at the beginning of a statement when the stack (holding
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
592 ;; nested statement info) is empty and the position has been moved.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
593 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
594 ;; The following variables constitute the PDA:
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
595 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
596 ;; sym: This is either the "while"-like token (e.g. 'for) we've just
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
597 ;; scanned back over, 'boundary if we've just gone back over a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
598 ;; statement boundary, or nil otherwise.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
599 ;; state: takes one of the values (nil else else-boundary while
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
600 ;; while-boundary catch catch-boundary).
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
601 ;; nil means "no "while"-like token yet scanned".
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
602 ;; 'else, for example, means "just gone back over an else".
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
603 ;; 'else-boundary means "just gone back over a statement boundary
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
604 ;; immediately after having gone back over an else".
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
605 ;; saved-pos: A vector of either saved positions (tok ptok pptok, etc.) or
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
606 ;; of error reporting information.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
607 ;; stack: The stack onto which the PDA pushes its state. Each entry
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
608 ;; consists of a saved value of state and saved-pos. An entry is
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
609 ;; pushed when we move back over a "continuation" token (e.g. else)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
610 ;; and popped when we encounter the corresponding opening token
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
611 ;; (e.g. if).
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
612 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
613 ;;
79408
a29ca195b71e (c-crosses-statement-barrier-p): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 78656
diff changeset
614 ;; The following diagram briefly outlines the PDA.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
615 ;;
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
616 ;; Common state:
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
617 ;; "else": Push state, goto state `else'.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
618 ;; "while": Push state, goto state `while'.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
619 ;; "catch" or "finally": Push state, goto state `catch'.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
620 ;; boundary: Pop state.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
621 ;; other: Do nothing special.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
622 ;;
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
623 ;; State `else':
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
624 ;; boundary: Goto state `else-boundary'.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
625 ;; other: Error, pop state, retry token.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
626 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
627 ;; State `else-boundary':
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
628 ;; "if": Pop state.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
629 ;; boundary: Error, pop state.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
630 ;; other: See common state.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
631 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
632 ;; State `while':
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
633 ;; boundary: Save position, goto state `while-boundary'.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
634 ;; other: Pop state, retry token.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
635 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
636 ;; State `while-boundary':
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
637 ;; "do": Pop state.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
638 ;; boundary: Restore position if it's not at start, pop state. [*see below]
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
639 ;; other: See common state.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
640 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
641 ;; State `catch':
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
642 ;; boundary: Goto state `catch-boundary'.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
643 ;; other: Error, pop state, retry token.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
644 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
645 ;; State `catch-boundary':
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
646 ;; "try": Pop state.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
647 ;; "catch": Goto state `catch'.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
648 ;; boundary: Error, pop state.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
649 ;; other: See common state.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
650 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
651 ;; [*] In the `while-boundary' state, we had pushed a 'while state, and were
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
652 ;; searching for a "do" which would have opened a do-while. If we didn't
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
653 ;; find it, we discard the analysis done since the "while", go back to this
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
654 ;; token in the buffer and restart the scanning there, this time WITHOUT
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
655 ;; pushing the 'while state onto the stack.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
656 ;;
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
657 ;; In addition to the above there is some special handling of labels
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
658 ;; and macros.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
659
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
660 (let ((case-fold-search nil)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
661 (start (point))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
662 macro-start
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
663 (delims (if comma-delim '(?\; ?,) '(?\;)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
664 (c-stmt-delim-chars (if comma-delim
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
665 c-stmt-delim-chars-with-comma
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
666 c-stmt-delim-chars))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
667 c-in-literal-cache c-maybe-labelp saved
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
668 ;; Current position.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
669 pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
670 ;; Position of last stmt boundary character (e.g. ;).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
671 boundary-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
672 ;; The position of the last sexp or bound that follows the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
673 ;; first found colon, i.e. the start of the nonlabel part of
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
674 ;; the statement. It's `start' if a colon is found just after
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
675 ;; the start.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
676 after-labels-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
677 ;; Like `after-labels-pos', but the first such position inside
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
678 ;; a label, i.e. the start of the last label before the start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
679 ;; of the nonlabel part of the statement.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
680 last-label-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
681 ;; The last position where a label is possible provided the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
682 ;; statement started there. It's nil as long as no invalid
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
683 ;; label content has been found (according to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
684 ;; `c-nonlabel-token-key'. It's `start' if no valid label
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
685 ;; content was found in the label. Note that we might still
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
686 ;; regard it a label if it starts with `c-label-kwds'.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
687 label-good-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
688 ;; Symbol just scanned back over (e.g. 'while or 'boundary).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
689 ;; See above.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
690 sym
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
691 ;; Current state in the automaton. See above.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
692 state
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
693 ;; Current saved positions. See above.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
694 saved-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
695 ;; Stack of conses (state . saved-pos).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
696 stack
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
697 ;; Regexp which matches "for", "if", etc.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
698 (cond-key (or c-opt-block-stmt-key
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
699 "\\<\\>")) ; Matches nothing.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
700 ;; Return value.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
701 (ret 'same)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
702 ;; Positions of the last three sexps or bounds we've stopped at.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
703 tok ptok pptok)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
704
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
705 (save-restriction
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
706 (if lim (narrow-to-region lim (point-max)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
707
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
708 (if (save-excursion
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
709 (and (c-beginning-of-macro)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
710 (/= (point) start)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
711 (setq macro-start (point)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
712
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
713 ;; Try to skip back over unary operator characters, to register
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
714 ;; that we've moved.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
715 (while (progn
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
716 (setq pos (point))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
717 (c-backward-syntactic-ws)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
718 ;; Protect post-++/-- operators just before a virtual semicolon.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
719 (and (not (c-at-vsemi-p))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
720 (/= (skip-chars-backward "-+!*&~@`#") 0))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
721
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
722 ;; Skip back over any semicolon here. If it was a bare semicolon, we're
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
723 ;; done. Later on we ignore the boundaries for statements that don't
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
724 ;; contain any sexp. The only thing that is affected is that the error
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
725 ;; checking is a little less strict, and we really don't bother.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
726 (if (and (memq (char-before) delims)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
727 (progn (forward-char -1)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
728 (setq saved (point))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
729 (c-backward-syntactic-ws)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
730 (or (memq (char-before) delims)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
731 (memq (char-before) '(?: nil))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
732 (eq (char-syntax (char-before)) ?\()
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
733 (c-at-vsemi-p))))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
734 (setq ret 'previous
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
735 pos saved)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
736
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
737 ;; Begin at start and not pos to detect macros if we stand
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
738 ;; directly after the #.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
739 (goto-char start)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
740 (if (looking-at "\\<\\|\\W")
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
741 ;; Record this as the first token if not starting inside it.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
742 (setq tok start))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
743
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
744 ;; The following while loop goes back one sexp (balanced parens,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
745 ;; etc. with contents, or symbol or suchlike) each iteration. This
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
746 ;; movement is accomplished with a call to scan-sexps approx 130 lines
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
747 ;; below.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
748 (while
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
749 (catch 'loop ;; Throw nil to break, non-nil to continue.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
750 (cond
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
751 ((save-excursion
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
752 (and macro-start ; Always NIL for AWK.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
753 (progn (skip-chars-backward " \t")
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
754 (eq (char-before) ?#))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
755 (progn (setq saved (1- (point)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
756 (beginning-of-line)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
757 (not (eq (char-before (1- (point))) ?\\)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
758 (looking-at c-opt-cpp-start)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
759 (progn (skip-chars-forward " \t")
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
760 (eq (point) saved))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
761 (goto-char saved)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
762 (if (and (c-forward-to-cpp-define-body)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
763 (progn (c-forward-syntactic-ws start)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
764 (< (point) start)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
765 ;; Stop at the first token in the content of the macro.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
766 (setq pos (point)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
767 ignore-labels t) ; Avoid the label check on exit.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
768 (setq pos saved
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
769 ret 'macro
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
770 ignore-labels t))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
771 (throw 'loop nil))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
772
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
773 ;; Do a round through the automaton if we've just passed a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
774 ;; statement boundary or passed a "while"-like token.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
775 ((or sym
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
776 (and (looking-at cond-key)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
777 (setq sym (intern (match-string 1)))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
778
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
779 (when (and (< pos start) (null stack))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
780 (throw 'loop nil))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
781
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
782 ;; The PDA state handling.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
783 ;;
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
784 ;; Refer to the description of the PDA in the opening
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
785 ;; comments. In the following OR form, the first leaf
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
786 ;; attempts to handles one of the specific actions detailed
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
787 ;; (e.g., finding token "if" whilst in state `else-boundary').
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
788 ;; We drop through to the second leaf (which handles common
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
789 ;; state) if no specific handler is found in the first cond.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
790 ;; If a parsing error is detected (e.g. an "else" with no
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
791 ;; preceding "if"), we throw to the enclosing catch.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
792 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
793 ;; Note that the (eq state 'else) means
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
794 ;; "we've just passed an else", NOT "we're looking for an
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
795 ;; else".
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
796 (or (cond
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
797 ((eq state 'else)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
798 (if (eq sym 'boundary)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
799 (setq state 'else-boundary)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
800 (c-bos-report-error)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
801 (c-bos-pop-state-and-retry)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
802
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
803 ((eq state 'else-boundary)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
804 (cond ((eq sym 'if)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
805 (c-bos-pop-state (setq ret 'beginning)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
806 ((eq sym 'boundary)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
807 (c-bos-report-error)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
808 (c-bos-pop-state))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
809
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
810 ((eq state 'while)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
811 (if (and (eq sym 'boundary)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
812 ;; Since this can cause backtracking we do a
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
813 ;; little more careful analysis to avoid it:
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
814 ;; If there's a label in front of the while
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
815 ;; it can't be part of a do-while.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
816 (not after-labels-pos))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
817 (progn (c-bos-save-pos)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
818 (setq state 'while-boundary))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
819 (c-bos-pop-state-and-retry))) ; Can't be a do-while
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
820
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
821 ((eq state 'while-boundary)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
822 (cond ((eq sym 'do)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
823 (c-bos-pop-state (setq ret 'beginning)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
824 ((eq sym 'boundary) ; isn't a do-while
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
825 (c-bos-restore-pos) ; the position of the while
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
826 (c-bos-pop-state)))) ; no longer searching for do.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
827
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
828 ((eq state 'catch)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
829 (if (eq sym 'boundary)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
830 (setq state 'catch-boundary)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
831 (c-bos-report-error)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
832 (c-bos-pop-state-and-retry)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
833
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
834 ((eq state 'catch-boundary)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
835 (cond
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
836 ((eq sym 'try)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
837 (c-bos-pop-state (setq ret 'beginning)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
838 ((eq sym 'catch)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
839 (setq state 'catch))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
840 ((eq sym 'boundary)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
841 (c-bos-report-error)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
842 (c-bos-pop-state)))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
843
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
844 ;; This is state common. We get here when the previous
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
845 ;; cond statement found no particular state handler.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
846 (cond ((eq sym 'boundary)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
847 ;; If we have a boundary at the start
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
848 ;; position we push a frame to go to the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
849 ;; previous statement.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
850 (if (>= pos start)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
851 (c-bos-push-state)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
852 (c-bos-pop-state)))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
853 ((eq sym 'else)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
854 (c-bos-push-state)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
855 (c-bos-save-error-info 'if 'else)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
856 (setq state 'else))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
857 ((eq sym 'while)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
858 ;; Is this a real while, or a do-while?
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
859 ;; The next `when' triggers unless we are SURE that
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
860 ;; the `while' is not the tailend of a `do-while'.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
861 (when (or (not pptok)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
862 (memq (char-after pptok) delims)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
863 ;; The following kludge is to prevent
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
864 ;; infinite recursion when called from
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
865 ;; c-awk-after-if-for-while-condition-p,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
866 ;; or the like.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
867 (and (eq (point) start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
868 (c-vsemi-status-unknown-p))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
869 (c-at-vsemi-p pptok))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
870 ;; Since this can cause backtracking we do a
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
871 ;; little more careful analysis to avoid it: If
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
872 ;; the while isn't followed by a (possibly
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
873 ;; virtual) semicolon it can't be a do-while.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
874 (c-bos-push-state)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
875 (setq state 'while)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
876 ((memq sym '(catch finally))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
877 (c-bos-push-state)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
878 (c-bos-save-error-info 'try sym)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
879 (setq state 'catch))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
880
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
881 (when c-maybe-labelp
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
882 ;; We're either past a statement boundary or at the
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
883 ;; start of a statement, so throw away any label data
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
884 ;; for the previous one.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
885 (setq after-labels-pos nil
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
886 last-label-pos nil
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
887 c-maybe-labelp nil))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
888
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
889 ;; Step to the previous sexp, but not if we crossed a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
890 ;; boundary, since that doesn't consume an sexp.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
891 (if (eq sym 'boundary)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
892 (setq ret 'previous)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
893
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
894 ;; HERE IS THE SINGLE PLACE INSIDE THE PDA LOOP WHERE WE MOVE
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
895 ;; BACKWARDS THROUGH THE SOURCE.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
896
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
897 ;; This is typically fast with the caching done by
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
898 ;; c-(backward|forward)-sws.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
899 (c-backward-syntactic-ws)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
900
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
901 (let ((before-sws-pos (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
902 ;; Set as long as we have to continue jumping by sexps.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
903 ;; It's the position to use as end in the next round.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
904 sexp-loop-continue-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
905 ;; The end position of the area to search for statement
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
906 ;; barriers in this round.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
907 (sexp-loop-end-pos pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
908
69140
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
909 ;; The following while goes back one sexp per iteration.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
910 (while
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
911 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
912 (unless (c-safe (c-backward-sexp) t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
913 ;; Give up if we hit an unbalanced block. Since the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
914 ;; stack won't be empty the code below will report a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
915 ;; suitable error.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
916 (throw 'loop nil))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
917
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
918 ;; Check if the sexp movement crossed a statement or
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
919 ;; declaration boundary. But first modify the point
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
920 ;; so that `c-crosses-statement-barrier-p' only looks
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
921 ;; at the non-sexp chars following the sexp.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
922 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
923 (when (setq
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
924 boundary-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
925 (cond
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
926 ((if macro-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
927 nil
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
928 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
929 (when (c-beginning-of-macro)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
930 ;; Set continuation position in case
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
931 ;; `c-crosses-statement-barrier-p'
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
932 ;; doesn't detect anything below.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
933 (setq sexp-loop-continue-pos (point)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
934 ;; If the sexp movement took us into a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
935 ;; macro then there were only some non-sexp
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
936 ;; chars after it. Skip out of the macro
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
937 ;; to analyze them but not the non-sexp
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
938 ;; chars that might be inside the macro.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
939 (c-end-of-macro)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
940 (c-crosses-statement-barrier-p
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
941 (point) sexp-loop-end-pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
942
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
943 ((and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
944 (eq (char-after) ?{)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
945 (not (c-looking-at-inexpr-block lim nil t)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
946 ;; Passed a block sexp. That's a boundary
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
947 ;; alright.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
948 (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
949
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
950 ((looking-at "\\s\(")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
951 ;; Passed some other paren. Only analyze
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
952 ;; the non-sexp chars after it.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
953 (goto-char (1+ (c-down-list-backward
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
954 before-sws-pos)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
955 ;; We're at a valid token start position
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
956 ;; (outside the `save-excursion') if
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
957 ;; `c-crosses-statement-barrier-p' failed.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
958 (c-crosses-statement-barrier-p
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
959 (point) sexp-loop-end-pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
960
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
961 (t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
962 ;; Passed a symbol sexp or line
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
963 ;; continuation. It doesn't matter that
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
964 ;; it's included in the analyzed region.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
965 (if (c-crosses-statement-barrier-p
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
966 (point) sexp-loop-end-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
967 t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
968 ;; If it was a line continuation then we
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
969 ;; have to continue looping.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
970 (if (looking-at "\\\\$")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
971 (setq sexp-loop-continue-pos (point)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
972 nil))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
973
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
974 (setq pptok ptok
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
975 ptok tok
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
976 tok boundary-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
977 sym 'boundary)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
978 ;; Like a C "continue". Analyze the next sexp.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
979 (throw 'loop t)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
980
69140
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
981 sexp-loop-continue-pos) ; End of "go back a sexp" loop.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
982 (goto-char sexp-loop-continue-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
983 (setq sexp-loop-end-pos sexp-loop-continue-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
984 sexp-loop-continue-pos nil))))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
985
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
986 ;; ObjC method def?
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
987 (when (and c-opt-method-key
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
988 (setq saved (c-in-method-def-p)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
989 (setq pos saved
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
990 ignore-labels t) ; Avoid the label check on exit.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
991 (throw 'loop nil))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
992
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
993 ;; Handle labels.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
994 (unless (eq ignore-labels t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
995 (when (numberp c-maybe-labelp)
69140
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
996 ;; `c-crosses-statement-barrier-p' has found a colon, so we
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
997 ;; might be in a label now. Have we got a real label
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
998 ;; (including a case label) or something like C++'s "public:"?
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
999 (if (or (not (looking-at c-nonlabel-token-key)) ; proper label
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
1000 (save-excursion ; e.g. "case 'a':" ?
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
1001 (and (c-safe (c-backward-sexp) t)
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
1002 (looking-at "\\<case\\>")))) ; FIXME!!! this is
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
1003 ; wrong for AWK. 2006/1/14.
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
1004 (progn
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
1005 (if after-labels-pos ; Have we already encountered a label?
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
1006 (if (not last-label-pos)
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
1007 (setq last-label-pos (or tok start)))
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
1008 (setq after-labels-pos (or tok start)))
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
1009 (setq c-maybe-labelp t
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
1010 label-good-pos nil))
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
1011 (setq c-maybe-labelp nil))) ; bogus "label"
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
1012
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
1013 (when (and (not label-good-pos) ; i.e. no invalid "label"'s yet
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
1014 ; been found.
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
1015 (looking-at c-nonlabel-token-key)) ; e.g. "while :"
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1016 ;; We're in a potential label and it's the first
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1017 ;; time we've found something that isn't allowed in
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1018 ;; one.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1019 (setq label-good-pos (or tok start))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1020
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1021 ;; We've moved back by a sexp, so update the token positions.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1022 (setq sym nil
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1023 pptok ptok
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1024 ptok tok
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1025 tok (point)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1026 pos tok))) ; Not nil (for the while loop).
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1027
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1028 ;; If the stack isn't empty there might be errors to report.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1029 (while stack
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1030 (if (and (vectorp saved-pos) (eq (length saved-pos) 3))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1031 (c-bos-report-error))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1032 (setq saved-pos (cdr (car stack))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1033 stack (cdr stack)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1034
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1035 (when (and (eq ret 'same)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1036 (not (memq sym '(boundary ignore nil))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1037 ;; Need to investigate closer whether we've crossed
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1038 ;; between a substatement and its containing statement.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1039 (if (setq saved (if (looking-at c-block-stmt-1-key)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1040 ptok
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1041 pptok))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1042 (cond ((> start saved) (setq pos saved))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1043 ((= start saved) (setq ret 'up)))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1044
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1045 (when (and (not ignore-labels)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1046 (eq c-maybe-labelp t)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1047 (not (eq ret 'beginning))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1048 after-labels-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1049 (or (not label-good-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1050 (<= label-good-pos pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1051 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1052 (goto-char (if (and last-label-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1053 (< last-label-pos start))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1054 last-label-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1055 pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1056 (looking-at c-label-kwds-regexp))))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1057 ;; We're in a label. Maybe we should step to the statement
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1058 ;; after it.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1059 (if (< after-labels-pos start)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1060 (setq pos after-labels-pos)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1061 (setq ret 'label)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1062 (if (and last-label-pos (< last-label-pos start))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1063 ;; Might have jumped over several labels. Go to the last one.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1064 (setq pos last-label-pos)))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1065
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1066 ;; Skip over the unary operators that can start the statement.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1067 (goto-char pos)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1068 (while (progn
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1069 (c-backward-syntactic-ws)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1070 ;; protect AWK post-inc/decrement operators, etc.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1071 (and (not (c-at-vsemi-p (point)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1072 (/= (skip-chars-backward "-+!*&~@`#") 0)))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1073 (setq pos (point)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1074 (goto-char pos)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1075 ret)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1076
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1077 (defun c-crosses-statement-barrier-p (from to)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1078 "Return non-nil if buffer positions FROM to TO cross one or more
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1079 statement or declaration boundaries. The returned value is actually
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1080 the position of the earliest boundary char. FROM must not be within
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1081 a string or comment.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1082
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1083 The variable `c-maybe-labelp' is set to the position of the first `:' that
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1084 might start a label (i.e. not part of `::' and not preceded by `?'). If a
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1085 single `?' is found, then `c-maybe-labelp' is cleared.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1086
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1087 For AWK, a statement which is terminated by an EOL (not a \; or a }) is
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1088 regarded as having a \"virtual semicolon\" immediately after the last token on
79408
a29ca195b71e (c-crosses-statement-barrier-p): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 78656
diff changeset
1089 the line. If this virtual semicolon is _at_ from, the function recognizes it.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1090
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1091 Note that this function might do hidden buffer changes. See the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1092 comment at the start of cc-engine.el for more info."
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1093 (let ((skip-chars c-stmt-delim-chars)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1094 lit-range)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1095 (save-excursion
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1096 (catch 'done
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1097 (goto-char from)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1098 (while (progn (skip-chars-forward skip-chars to)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1099 (< (point) to))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1100 (cond
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1101 ((setq lit-range (c-literal-limits from)) ; Have we landed in a string/comment?
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1102 (goto-char (cdr lit-range)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1103 ((eq (char-after) ?:)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1104 (forward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1105 (if (and (eq (char-after) ?:)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1106 (< (point) to))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1107 ;; Ignore scope operators.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1108 (forward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1109 (setq c-maybe-labelp (1- (point)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1110 ((eq (char-after) ??)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1111 ;; A question mark. Can't be a label, so stop
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1112 ;; looking for more : and ?.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1113 (setq c-maybe-labelp nil
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1114 skip-chars (substring c-stmt-delim-chars 0 -2)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1115 ((memq (char-after) '(?# ?\n ?\r)) ; A virtual semicolon?
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1116 (if (and (eq (char-before) ?\\) (memq (char-after) '(?\n ?\r)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1117 (backward-char))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1118 (skip-chars-backward " \t" from)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1119 (if (c-at-vsemi-p)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1120 (throw 'done (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1121 (forward-line)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1122 (t (throw 'done (point)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1123 ;; In trailing space after an as yet undetected virtual semicolon?
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1124 (c-backward-syntactic-ws from)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1125 (if (and (< (point) to)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1126 (c-at-vsemi-p))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1127 (point)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1128 nil)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1129
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1130 (defun c-at-statement-start-p ()
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1131 "Return non-nil if the point is at the first token in a statement
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1132 or somewhere in the syntactic whitespace before it.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1133
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1134 A \"statement\" here is not restricted to those inside code blocks.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1135 Any kind of declaration-like construct that occur outside function
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1136 bodies is also considered a \"statement\".
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1137
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1138 Note that this function might do hidden buffer changes. See the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1139 comment at the start of cc-engine.el for more info."
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1140
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1141 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1142 (let ((end (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1143 c-maybe-labelp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1144 (c-syntactic-skip-backward (substring c-stmt-delim-chars 1) nil t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1145 (or (bobp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1146 (eq (char-before) ?})
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1147 (and (eq (char-before) ?{)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1148 (not (and c-special-brace-lists
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1149 (progn (backward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1150 (c-looking-at-special-brace-list)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1151 (c-crosses-statement-barrier-p (point) end)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1152
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1153 (defun c-at-expression-start-p ()
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1154 "Return non-nil if the point is at the first token in an expression or
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1155 statement, or somewhere in the syntactic whitespace before it.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1156
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1157 An \"expression\" here is a bit different from the normal language
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1158 grammar sense: It's any sequence of expression tokens except commas,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1159 unless they are enclosed inside parentheses of some kind. Also, an
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1160 expression never continues past an enclosing parenthesis, but it might
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1161 contain parenthesis pairs of any sort except braces.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1162
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1163 Since expressions never cross statement boundaries, this function also
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1164 recognizes statement beginnings, just like `c-at-statement-start-p'.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1165
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1166 Note that this function might do hidden buffer changes. See the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1167 comment at the start of cc-engine.el for more info."
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1168
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1169 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1170 (let ((end (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1171 (c-stmt-delim-chars c-stmt-delim-chars-with-comma)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1172 c-maybe-labelp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1173 (c-syntactic-skip-backward (substring c-stmt-delim-chars 1) nil t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1174 (or (bobp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1175 (memq (char-before) '(?{ ?}))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1176 (save-excursion (backward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1177 (looking-at "\\s("))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1178 (c-crosses-statement-barrier-p (point) end)))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1179
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1180
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1181 ;; A set of functions that covers various idiosyncrasies in
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1182 ;; implementations of `forward-comment'.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1183
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1184 ;; Note: Some emacsen considers incorrectly that any line comment
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1185 ;; ending with a backslash continues to the next line. I can't think
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1186 ;; of any way to work around that in a reliable way without changing
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1187 ;; the buffer, though. Suggestions welcome. ;) (No, temporarily
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1188 ;; changing the syntax for backslash doesn't work since we must treat
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1189 ;; escapes in string literals correctly.)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1190
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1191 (defun c-forward-single-comment ()
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1192 "Move forward past whitespace and the closest following comment, if any.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1193 Return t if a comment was found, nil otherwise. In either case, the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1194 point is moved past the following whitespace. Line continuations,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1195 i.e. a backslashes followed by line breaks, are treated as whitespace.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1196 The line breaks that end line comments are considered to be the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1197 comment enders, so the point will be put on the beginning of the next
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1198 line if it moved past a line comment.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1199
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1200 This function does not do any hidden buffer changes."
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1201
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1202 (let ((start (point)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1203 (when (looking-at "\\([ \t\n\r\f\v]\\|\\\\[\n\r]\\)+")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1204 (goto-char (match-end 0)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1205
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1206 (when (forward-comment 1)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1207 (if (eobp)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1208 ;; Some emacsen (e.g. XEmacs 21) return t when moving
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1209 ;; forwards at eob.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1210 nil
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1211
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1212 ;; Emacs includes the ending newline in a b-style (c++)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1213 ;; comment, but XEmacs doesn't. We depend on the Emacs
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1214 ;; behavior (which also is symmetric).
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1215 (if (and (eolp) (elt (parse-partial-sexp start (point)) 7))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1216 (condition-case nil (forward-char 1)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1217
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1218 t))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1219
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1220 (defsubst c-forward-comments ()
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1221 "Move forward past all following whitespace and comments.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1222 Line continuations, i.e. a backslashes followed by line breaks, are
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1223 treated as whitespace.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1224
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1225 Note that this function might do hidden buffer changes. See the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1226 comment at the start of cc-engine.el for more info."
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1227
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1228 (while (or
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1229 ;; If forward-comment in at least XEmacs 21 is given a large
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1230 ;; positive value, it'll loop all the way through if it hits
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1231 ;; eob.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1232 (and (forward-comment 5)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1233 ;; Some emacsen (e.g. XEmacs 21) return t when moving
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1234 ;; forwards at eob.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1235 (not (eobp)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1236
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1237 (when (looking-at "\\\\[\n\r]")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1238 (forward-char 2)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1239 t))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1240
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1241 (defun c-backward-single-comment ()
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1242 "Move backward past whitespace and the closest preceding comment, if any.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1243 Return t if a comment was found, nil otherwise. In either case, the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1244 point is moved past the preceding whitespace. Line continuations,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1245 i.e. a backslashes followed by line breaks, are treated as whitespace.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1246 The line breaks that end line comments are considered to be the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1247 comment enders, so the point cannot be at the end of the same line to
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1248 move over a line comment.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1249
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1250 This function does not do any hidden buffer changes."
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1251
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1252 (let ((start (point)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1253 ;; When we got newline terminated comments, forward-comment in all
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1254 ;; supported emacsen so far will stop at eol of each line not
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1255 ;; ending with a comment when moving backwards. This corrects for
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1256 ;; that, and at the same time handles line continuations.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1257 (while (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1258 (skip-chars-backward " \t\n\r\f\v")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1259 (and (looking-at "[\n\r]")
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1260 (eq (char-before) ?\\)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1261 (backward-char))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1262
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1263 (if (bobp)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1264 ;; Some emacsen (e.g. Emacs 19.34) return t when moving
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1265 ;; backwards at bob.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1266 nil
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1267
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1268 ;; Leave point after the closest following newline if we've
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1269 ;; backed up over any above, since forward-comment won't move
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1270 ;; backward over a line comment if point is at the end of the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1271 ;; same line.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1272 (re-search-forward "\\=\\s *[\n\r]" start t)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1273
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1274 (if (if (forward-comment -1)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1275 (if (eolp)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1276 ;; If forward-comment above succeeded and we're at eol
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1277 ;; then the newline we moved over above didn't end a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1278 ;; line comment, so we give it another go.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1279 (forward-comment -1)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1280 t))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1281
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1282 ;; Emacs <= 20 and XEmacs move back over the closer of a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1283 ;; block comment that lacks an opener.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1284 (if (looking-at "\\*/")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1285 (progn (forward-char 2) nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1286 t)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1287
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1288 (defsubst c-backward-comments ()
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1289 "Move backward past all preceding whitespace and comments.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1290 Line continuations, i.e. a backslashes followed by line breaks, are
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1291 treated as whitespace. The line breaks that end line comments are
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1292 considered to be the comment enders, so the point cannot be at the end
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1293 of the same line to move over a line comment. Unlike
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1294 c-backward-syntactic-ws, this function doesn't move back over
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1295 preprocessor directives.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1296
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1297 Note that this function might do hidden buffer changes. See the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1298 comment at the start of cc-engine.el for more info."
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1299
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1300 (let ((start (point)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1301 (while (and
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1302 ;; `forward-comment' in some emacsen (e.g. XEmacs 21.4)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1303 ;; return t when moving backwards at bob.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1304 (not (bobp))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1305
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1306 (if (forward-comment -1)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1307 (if (looking-at "\\*/")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1308 ;; Emacs <= 20 and XEmacs move back over the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1309 ;; closer of a block comment that lacks an opener.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1310 (progn (forward-char 2) nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1311 t)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1312
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1313 ;; XEmacs treats line continuations as whitespace but
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1314 ;; only in the backward direction, which seems a bit
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1315 ;; odd. Anyway, this is necessary for Emacs.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1316 (when (and (looking-at "[\n\r]")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1317 (eq (char-before) ?\\)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1318 (< (point) start))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1319 (backward-char)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1320 t))))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1321
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1322
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1323 ;; Tools for skipping over syntactic whitespace.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1324
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1325 ;; The following functions use text properties to cache searches over
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1326 ;; large regions of syntactic whitespace. It works as follows:
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1327 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1328 ;; o If a syntactic whitespace region contains anything but simple
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1329 ;; whitespace (i.e. space, tab and line breaks), the text property
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1330 ;; `c-in-sws' is put over it. At places where we have stopped
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1331 ;; within that region there's also a `c-is-sws' text property.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1332 ;; That since there typically are nested whitespace inside that
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1333 ;; must be handled separately, e.g. whitespace inside a comment or
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1334 ;; cpp directive. Thus, from one point with `c-is-sws' it's safe
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1335 ;; to jump to another point with that property within the same
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1336 ;; `c-in-sws' region. It can be likened to a ladder where
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1337 ;; `c-in-sws' marks the bars and `c-is-sws' the rungs.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1338 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1339 ;; o The `c-is-sws' property is put on the simple whitespace chars at
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1340 ;; a "rung position" and also maybe on the first following char.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1341 ;; As many characters as can be conveniently found in this range
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1342 ;; are marked, but no assumption can be made that the whole range
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1343 ;; is marked (it could be clobbered by later changes, for
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1344 ;; instance).
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1345 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1346 ;; Note that some part of the beginning of a sequence of simple
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1347 ;; whitespace might be part of the end of a preceding line comment
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1348 ;; or cpp directive and must not be considered part of the "rung".
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1349 ;; Such whitespace is some amount of horizontal whitespace followed
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1350 ;; by a newline. In the case of cpp directives it could also be
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1351 ;; two newlines with horizontal whitespace between them.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1352 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1353 ;; The reason to include the first following char is to cope with
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1354 ;; "rung positions" that doesn't have any ordinary whitespace. If
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1355 ;; `c-is-sws' is put on a token character it does not have
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1356 ;; `c-in-sws' set simultaneously. That's the only case when that
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1357 ;; can occur, and the reason for not extending the `c-in-sws'
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1358 ;; region to cover it is that the `c-in-sws' region could then be
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1359 ;; accidentally merged with a following one if the token is only
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1360 ;; one character long.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1361 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1362 ;; o On buffer changes the `c-in-sws' and `c-is-sws' properties are
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1363 ;; removed in the changed region. If the change was inside
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1364 ;; syntactic whitespace that means that the "ladder" is broken, but
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1365 ;; a later call to `c-forward-sws' or `c-backward-sws' will use the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1366 ;; parts on either side and use an ordinary search only to "repair"
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1367 ;; the gap.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1368 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1369 ;; Special care needs to be taken if a region is removed: If there
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1370 ;; are `c-in-sws' on both sides of it which do not connect inside
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1371 ;; the region then they can't be joined. If e.g. a marked macro is
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1372 ;; broken, syntactic whitespace inside the new text might be
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1373 ;; marked. If those marks would become connected with the old
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1374 ;; `c-in-sws' range around the macro then we could get a ladder
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1375 ;; with one end outside the macro and the other at some whitespace
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1376 ;; within it.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1377 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1378 ;; The main motivation for this system is to increase the speed in
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1379 ;; skipping over the large whitespace regions that can occur at the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1380 ;; top level in e.g. header files that contain a lot of comments and
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1381 ;; cpp directives. For small comments inside code it's probably
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1382 ;; slower than using `forward-comment' straightforwardly, but speed is
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1383 ;; not a significant factor there anyway.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1384
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1385 ; (defface c-debug-is-sws-face
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1386 ; '((t (:background "GreenYellow")))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1387 ; "Debug face to mark the `c-is-sws' property.")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1388 ; (defface c-debug-in-sws-face
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1389 ; '((t (:underline t)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1390 ; "Debug face to mark the `c-in-sws' property.")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1391
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1392 ; (defun c-debug-put-sws-faces ()
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1393 ; ;; Put the sws debug faces on all the `c-is-sws' and `c-in-sws'
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1394 ; ;; properties in the buffer.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1395 ; (interactive)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1396 ; (save-excursion
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1397 ; (c-save-buffer-state (in-face)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1398 ; (goto-char (point-min))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1399 ; (setq in-face (if (get-text-property (point) 'c-is-sws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1400 ; (point)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1401 ; (while (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1402 ; (goto-char (next-single-property-change
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1403 ; (point) 'c-is-sws nil (point-max)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1404 ; (if in-face
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1405 ; (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1406 ; (c-debug-add-face in-face (point) 'c-debug-is-sws-face)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1407 ; (setq in-face nil))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1408 ; (setq in-face (point)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1409 ; (not (eobp))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1410 ; (goto-char (point-min))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1411 ; (setq in-face (if (get-text-property (point) 'c-in-sws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1412 ; (point)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1413 ; (while (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1414 ; (goto-char (next-single-property-change
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1415 ; (point) 'c-in-sws nil (point-max)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1416 ; (if in-face
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1417 ; (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1418 ; (c-debug-add-face in-face (point) 'c-debug-in-sws-face)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1419 ; (setq in-face nil))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1420 ; (setq in-face (point)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1421 ; (not (eobp)))))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1422
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1423 (defmacro c-debug-sws-msg (&rest args)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1424 ;;`(message ,@args)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1425 )
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1426
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1427 (defmacro c-put-is-sws (beg end)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1428 ;; This macro does a hidden buffer change.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1429 `(let ((beg ,beg) (end ,end))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1430 (put-text-property beg end 'c-is-sws t)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1431 ,@(when (facep 'c-debug-is-sws-face)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1432 `((c-debug-add-face beg end 'c-debug-is-sws-face)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1433
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1434 (defmacro c-put-in-sws (beg end)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1435 ;; This macro does a hidden buffer change.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1436 `(let ((beg ,beg) (end ,end))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1437 (put-text-property beg end 'c-in-sws t)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1438 ,@(when (facep 'c-debug-is-sws-face)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1439 `((c-debug-add-face beg end 'c-debug-in-sws-face)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1440
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1441 (defmacro c-remove-is-sws (beg end)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1442 ;; This macro does a hidden buffer change.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1443 `(let ((beg ,beg) (end ,end))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1444 (remove-text-properties beg end '(c-is-sws nil))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1445 ,@(when (facep 'c-debug-is-sws-face)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1446 `((c-debug-remove-face beg end 'c-debug-is-sws-face)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1447
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1448 (defmacro c-remove-in-sws (beg end)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1449 ;; This macro does a hidden buffer change.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1450 `(let ((beg ,beg) (end ,end))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1451 (remove-text-properties beg end '(c-in-sws nil))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1452 ,@(when (facep 'c-debug-is-sws-face)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1453 `((c-debug-remove-face beg end 'c-debug-in-sws-face)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1454
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1455 (defmacro c-remove-is-and-in-sws (beg end)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1456 ;; This macro does a hidden buffer change.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1457 `(let ((beg ,beg) (end ,end))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1458 (remove-text-properties beg end '(c-is-sws nil c-in-sws nil))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1459 ,@(when (facep 'c-debug-is-sws-face)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1460 `((c-debug-remove-face beg end 'c-debug-is-sws-face)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1461 (c-debug-remove-face beg end 'c-debug-in-sws-face)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1462
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1463 (defsubst c-invalidate-sws-region-after (beg end)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1464 ;; Called from `after-change-functions'. Note that if
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1465 ;; `c-forward-sws' or `c-backward-sws' are used outside
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1466 ;; `c-save-buffer-state' or similar then this will remove the cache
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1467 ;; properties right after they're added.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1468 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1469 ;; This function does hidden buffer changes.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1470
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1471 (save-excursion
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1472 ;; Adjust the end to remove the properties in any following simple
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1473 ;; ws up to and including the next line break, if there is any
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1474 ;; after the changed region. This is necessary e.g. when a rung
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1475 ;; marked empty line is converted to a line comment by inserting
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1476 ;; "//" before the line break. In that case the line break would
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1477 ;; keep the rung mark which could make a later `c-backward-sws'
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1478 ;; move into the line comment instead of over it.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1479 (goto-char end)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1480 (skip-chars-forward " \t\f\v")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1481 (when (and (eolp) (not (eobp)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1482 (setq end (1+ (point)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1483
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1484 (when (and (= beg end)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1485 (get-text-property beg 'c-in-sws)
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
1486 (> beg (point-min))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1487 (get-text-property (1- beg) 'c-in-sws))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1488 ;; Ensure that an `c-in-sws' range gets broken. Note that it isn't
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1489 ;; safe to keep a range that was continuous before the change. E.g:
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1490 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1491 ;; #define foo
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1492 ;; \
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1493 ;; bar
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1494 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1495 ;; There can be a "ladder" between "#" and "b". Now, if the newline
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1496 ;; after "foo" is removed then "bar" will become part of the cpp
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1497 ;; directive instead of a syntactically relevant token. In that
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1498 ;; case there's no longer syntactic ws from "#" to "b".
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1499 (setq beg (1- beg)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1500
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1501 (c-debug-sws-msg "c-invalidate-sws-region-after [%s..%s]" beg end)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1502 (c-remove-is-and-in-sws beg end))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1503
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1504 (defun c-forward-sws ()
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1505 ;; Used by `c-forward-syntactic-ws' to implement the unbounded search.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1506 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1507 ;; This function might do hidden buffer changes.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1508
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1509 (let (;; `rung-pos' is set to a position as early as possible in the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1510 ;; unmarked part of the simple ws region.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1511 (rung-pos (point)) next-rung-pos rung-end-pos last-put-in-sws-pos
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1512 rung-is-marked next-rung-is-marked simple-ws-end
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1513 ;; `safe-start' is set when it's safe to cache the start position.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1514 ;; It's not set if we've initially skipped over comments and line
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1515 ;; continuations since we might have gone out through the end of a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1516 ;; macro then. This provision makes `c-forward-sws' not populate the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1517 ;; cache in the majority of cases, but otoh is `c-backward-sws' by far
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1518 ;; more common.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1519 safe-start)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1520
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1521 ;; Skip simple ws and do a quick check on the following character to see
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1522 ;; if it's anything that can't start syntactic ws, so we can bail out
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1523 ;; early in the majority of cases when there just are a few ws chars.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1524 (skip-chars-forward " \t\n\r\f\v")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1525 (when (looking-at c-syntactic-ws-start)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1526
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1527 (setq rung-end-pos (min (1+ (point)) (point-max)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1528 (if (setq rung-is-marked (text-property-any rung-pos rung-end-pos
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1529 'c-is-sws t))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1530 ;; Find the last rung position to avoid setting properties in all
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1531 ;; the cases when the marked rung is complete.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1532 ;; (`next-single-property-change' is certain to move at least one
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1533 ;; step forward.)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1534 (setq rung-pos (1- (next-single-property-change
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1535 rung-is-marked 'c-is-sws nil rung-end-pos)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1536 ;; Got no marked rung here. Since the simple ws might have started
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1537 ;; inside a line comment or cpp directive we must set `rung-pos' as
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1538 ;; high as possible.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1539 (setq rung-pos (point)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1540
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1541 (while
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1542 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1543 (while
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1544 (when (and rung-is-marked
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1545 (get-text-property (point) 'c-in-sws))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1546
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1547 ;; The following search is the main reason that `c-in-sws'
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1548 ;; and `c-is-sws' aren't combined to one property.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1549 (goto-char (next-single-property-change
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1550 (point) 'c-in-sws nil (point-max)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1551 (unless (get-text-property (point) 'c-is-sws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1552 ;; If the `c-in-sws' region extended past the last
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1553 ;; `c-is-sws' char we have to go back a bit.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1554 (or (get-text-property (1- (point)) 'c-is-sws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1555 (goto-char (previous-single-property-change
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1556 (point) 'c-is-sws)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1557 (backward-char))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1558
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1559 (c-debug-sws-msg
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1560 "c-forward-sws cached move %s -> %s (max %s)"
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1561 rung-pos (point) (point-max))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1562
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1563 (setq rung-pos (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1564 (and (> (skip-chars-forward " \t\n\r\f\v") 0)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1565 (not (eobp))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1566
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1567 ;; We'll loop here if there is simple ws after the last rung.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1568 ;; That means that there's been some change in it and it's
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1569 ;; possible that we've stepped into another ladder, so extend
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1570 ;; the previous one to join with it if there is one, and try to
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1571 ;; use the cache again.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1572 (c-debug-sws-msg
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1573 "c-forward-sws extending rung with [%s..%s] (max %s)"
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1574 (1+ rung-pos) (1+ (point)) (point-max))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1575 (unless (get-text-property (point) 'c-is-sws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1576 ;; Remove any `c-in-sws' property from the last char of
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1577 ;; the rung before we mark it with `c-is-sws', so that we
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1578 ;; won't connect with the remains of a broken "ladder".
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1579 (c-remove-in-sws (point) (1+ (point))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1580 (c-put-is-sws (1+ rung-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1581 (1+ (point)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1582 (c-put-in-sws rung-pos
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1583 (setq rung-pos (point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1584 last-put-in-sws-pos rung-pos)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1585
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1586 (setq simple-ws-end (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1587 (c-forward-comments)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1588
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1589 (cond
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1590 ((/= (point) simple-ws-end)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1591 ;; Skipped over comments. Don't cache at eob in case the buffer
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1592 ;; is narrowed.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1593 (not (eobp)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1594
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1595 ((save-excursion
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1596 (and c-opt-cpp-prefix
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1597 (looking-at c-opt-cpp-start)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1598 (progn (skip-chars-backward " \t")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1599 (bolp))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1600 (or (bobp)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1601 (progn (backward-char)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1602 (not (eq (char-before) ?\\))))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1603 ;; Skip a preprocessor directive.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1604 (end-of-line)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1605 (while (and (eq (char-before) ?\\)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1606 (= (forward-line 1) 0))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1607 (end-of-line))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1608 (forward-line 1)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1609 (setq safe-start t)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1610 ;; Don't cache at eob in case the buffer is narrowed.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1611 (not (eobp)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1612
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1613 ;; We've searched over a piece of non-white syntactic ws. See if this
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1614 ;; can be cached.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1615 (setq next-rung-pos (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1616 (skip-chars-forward " \t\n\r\f\v")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1617 (setq rung-end-pos (min (1+ (point)) (point-max)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1618
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1619 (if (or
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1620 ;; Cache if we haven't skipped comments only, and if we started
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1621 ;; either from a marked rung or from a completely uncached
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1622 ;; position.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1623 (and safe-start
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1624 (or rung-is-marked
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1625 (not (get-text-property simple-ws-end 'c-in-sws))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1626
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1627 ;; See if there's a marked rung in the encountered simple ws. If
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1628 ;; so then we can cache, unless `safe-start' is nil. Even then
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1629 ;; we need to do this to check if the cache can be used for the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1630 ;; next step.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1631 (and (setq next-rung-is-marked
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1632 (text-property-any next-rung-pos rung-end-pos
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1633 'c-is-sws t))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1634 safe-start))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1635
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1636 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1637 (c-debug-sws-msg
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1638 "c-forward-sws caching [%s..%s] - [%s..%s] (max %s)"
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1639 rung-pos (1+ simple-ws-end) next-rung-pos rung-end-pos
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1640 (point-max))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1641
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1642 ;; Remove the properties for any nested ws that might be cached.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1643 ;; Only necessary for `c-is-sws' since `c-in-sws' will be set
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1644 ;; anyway.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1645 (c-remove-is-sws (1+ simple-ws-end) next-rung-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1646 (unless (and rung-is-marked (= rung-pos simple-ws-end))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1647 (c-put-is-sws rung-pos
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1648 (1+ simple-ws-end))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1649 (setq rung-is-marked t))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1650 (c-put-in-sws rung-pos
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1651 (setq rung-pos (point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1652 last-put-in-sws-pos rung-pos))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1653 (unless (get-text-property (1- rung-end-pos) 'c-is-sws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1654 ;; Remove any `c-in-sws' property from the last char of
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1655 ;; the rung before we mark it with `c-is-sws', so that we
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1656 ;; won't connect with the remains of a broken "ladder".
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1657 (c-remove-in-sws (1- rung-end-pos) rung-end-pos))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1658 (c-put-is-sws next-rung-pos
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1659 rung-end-pos))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1660
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1661 (c-debug-sws-msg
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1662 "c-forward-sws not caching [%s..%s] - [%s..%s] (max %s)"
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1663 rung-pos (1+ simple-ws-end) next-rung-pos rung-end-pos
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1664 (point-max))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1665
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1666 ;; Set `rung-pos' for the next rung. It's the same thing here as
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1667 ;; initially, except that the rung position is set as early as
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1668 ;; possible since we can't be in the ending ws of a line comment or
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1669 ;; cpp directive now.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1670 (if (setq rung-is-marked next-rung-is-marked)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1671 (setq rung-pos (1- (next-single-property-change
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1672 rung-is-marked 'c-is-sws nil rung-end-pos)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1673 (setq rung-pos next-rung-pos))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1674 (setq safe-start t)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1675
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1676 ;; Make sure that the newly marked `c-in-sws' region doesn't connect to
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1677 ;; another one after the point (which might occur when editing inside a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1678 ;; comment or macro).
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1679 (when (eq last-put-in-sws-pos (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1680 (cond ((< last-put-in-sws-pos (point-max))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1681 (c-debug-sws-msg
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1682 "c-forward-sws clearing at %s for cache separation"
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1683 last-put-in-sws-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1684 (c-remove-in-sws last-put-in-sws-pos
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1685 (1+ last-put-in-sws-pos)))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1686 (t
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1687 ;; If at eob we have to clear the last character before the end
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1688 ;; instead since the buffer might be narrowed and there might
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1689 ;; be a `c-in-sws' after (point-max). In this case it's
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1690 ;; necessary to clear both properties.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1691 (c-debug-sws-msg
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1692 "c-forward-sws clearing thoroughly at %s for cache separation"
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1693 (1- last-put-in-sws-pos))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1694 (c-remove-is-and-in-sws (1- last-put-in-sws-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1695 last-put-in-sws-pos))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1696 )))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1697
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1698 (defun c-backward-sws ()
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1699 ;; Used by `c-backward-syntactic-ws' to implement the unbounded search.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1700 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1701 ;; This function might do hidden buffer changes.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1702
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1703 (let (;; `rung-pos' is set to a position as late as possible in the unmarked
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1704 ;; part of the simple ws region.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1705 (rung-pos (point)) next-rung-pos last-put-in-sws-pos
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1706 rung-is-marked simple-ws-beg cmt-skip-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1707
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1708 ;; Skip simple horizontal ws and do a quick check on the preceding
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1709 ;; character to see if it's anying that can't end syntactic ws, so we can
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1710 ;; bail out early in the majority of cases when there just are a few ws
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1711 ;; chars. Newlines are complicated in the backward direction, so we can't
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1712 ;; skip over them.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1713 (skip-chars-backward " \t\f")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1714 (when (and (not (bobp))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1715 (save-excursion
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1716 (backward-char)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1717 (looking-at c-syntactic-ws-end)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1718
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1719 ;; Try to find a rung position in the simple ws preceding point, so that
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1720 ;; we can get a cache hit even if the last bit of the simple ws has
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1721 ;; changed recently.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1722 (setq simple-ws-beg (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1723 (skip-chars-backward " \t\n\r\f\v")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1724 (if (setq rung-is-marked (text-property-any
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1725 (point) (min (1+ rung-pos) (point-max))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1726 'c-is-sws t))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1727 ;; `rung-pos' will be the earliest marked position, which means that
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1728 ;; there might be later unmarked parts in the simple ws region.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1729 ;; It's not worth the effort to fix that; the last part of the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1730 ;; simple ws is also typically edited often, so it could be wasted.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1731 (goto-char (setq rung-pos rung-is-marked))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1732 (goto-char simple-ws-beg))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1733
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1734 (while
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1735 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1736 (while
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1737 (when (and rung-is-marked
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1738 (not (bobp))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1739 (get-text-property (1- (point)) 'c-in-sws))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1740
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1741 ;; The following search is the main reason that `c-in-sws'
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1742 ;; and `c-is-sws' aren't combined to one property.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1743 (goto-char (previous-single-property-change
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1744 (point) 'c-in-sws nil (point-min)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1745 (unless (get-text-property (point) 'c-is-sws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1746 ;; If the `c-in-sws' region extended past the first
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1747 ;; `c-is-sws' char we have to go forward a bit.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1748 (goto-char (next-single-property-change
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1749 (point) 'c-is-sws)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1750
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1751 (c-debug-sws-msg
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1752 "c-backward-sws cached move %s <- %s (min %s)"
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1753 (point) rung-pos (point-min))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1754
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1755 (setq rung-pos (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1756 (if (and (< (min (skip-chars-backward " \t\f\v")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1757 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1758 (setq simple-ws-beg (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1759 (skip-chars-backward " \t\n\r\f\v")))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1760 0)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1761 (setq rung-is-marked
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1762 (text-property-any (point) rung-pos
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1763 'c-is-sws t)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1764 t
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1765 (goto-char simple-ws-beg)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1766 nil))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1767
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1768 ;; We'll loop here if there is simple ws before the first rung.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1769 ;; That means that there's been some change in it and it's
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1770 ;; possible that we've stepped into another ladder, so extend
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1771 ;; the previous one to join with it if there is one, and try to
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1772 ;; use the cache again.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1773 (c-debug-sws-msg
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1774 "c-backward-sws extending rung with [%s..%s] (min %s)"
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1775 rung-is-marked rung-pos (point-min))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1776 (unless (get-text-property (1- rung-pos) 'c-is-sws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1777 ;; Remove any `c-in-sws' property from the last char of
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1778 ;; the rung before we mark it with `c-is-sws', so that we
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1779 ;; won't connect with the remains of a broken "ladder".
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1780 (c-remove-in-sws (1- rung-pos) rung-pos))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1781 (c-put-is-sws rung-is-marked
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1782 rung-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1783 (c-put-in-sws rung-is-marked
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1784 (1- rung-pos))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1785 (setq rung-pos rung-is-marked
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1786 last-put-in-sws-pos rung-pos))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1787
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1788 (c-backward-comments)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1789 (setq cmt-skip-pos (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1790
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1791 (cond
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1792 ((and c-opt-cpp-prefix
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1793 (/= cmt-skip-pos simple-ws-beg)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1794 (c-beginning-of-macro))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1795 ;; Inside a cpp directive. See if it should be skipped over.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1796 (let ((cpp-beg (point)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1797
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1798 ;; Move back over all line continuations in the region skipped
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1799 ;; over by `c-backward-comments'. If we go past it then we
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1800 ;; started inside the cpp directive.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1801 (goto-char simple-ws-beg)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1802 (beginning-of-line)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1803 (while (and (> (point) cmt-skip-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1804 (progn (backward-char)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1805 (eq (char-before) ?\\)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1806 (beginning-of-line))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1807
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1808 (if (< (point) cmt-skip-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1809 ;; Don't move past the cpp directive if we began inside
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1810 ;; it. Note that the position at the end of the last line
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1811 ;; of the macro is also considered to be within it.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1812 (progn (goto-char cmt-skip-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1813 nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1814
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1815 ;; It's worthwhile to spend a little bit of effort on finding
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1816 ;; the end of the macro, to get a good `simple-ws-beg'
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1817 ;; position for the cache. Note that `c-backward-comments'
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1818 ;; could have stepped over some comments before going into
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1819 ;; the macro, and then `simple-ws-beg' must be kept on the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1820 ;; same side of those comments.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1821 (goto-char simple-ws-beg)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1822 (skip-chars-backward " \t\n\r\f\v")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1823 (if (eq (char-before) ?\\)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1824 (forward-char))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1825 (forward-line 1)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1826 (if (< (point) simple-ws-beg)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1827 ;; Might happen if comments after the macro were skipped
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1828 ;; over.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1829 (setq simple-ws-beg (point)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1830
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1831 (goto-char cpp-beg)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1832 t)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1833
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1834 ((/= (save-excursion
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1835 (skip-chars-forward " \t\n\r\f\v" simple-ws-beg)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1836 (setq next-rung-pos (point)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1837 simple-ws-beg)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1838 ;; Skipped over comments. Must put point at the end of
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1839 ;; the simple ws at point since we might be after a line
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1840 ;; comment or cpp directive that's been partially
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1841 ;; narrowed out, and we can't risk marking the simple ws
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1842 ;; at the end of it.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1843 (goto-char next-rung-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1844 t)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1845
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1846 ;; We've searched over a piece of non-white syntactic ws. See if this
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1847 ;; can be cached.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1848 (setq next-rung-pos (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1849 (skip-chars-backward " \t\f\v")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1850
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1851 (if (or
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1852 ;; Cache if we started either from a marked rung or from a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1853 ;; completely uncached position.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1854 rung-is-marked
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1855 (not (get-text-property (1- simple-ws-beg) 'c-in-sws))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1856
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1857 ;; Cache if there's a marked rung in the encountered simple ws.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1858 (save-excursion
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1859 (skip-chars-backward " \t\n\r\f\v")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1860 (text-property-any (point) (min (1+ next-rung-pos) (point-max))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1861 'c-is-sws t)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1862
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1863 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1864 (c-debug-sws-msg
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1865 "c-backward-sws caching [%s..%s] - [%s..%s] (min %s)"
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1866 (point) (1+ next-rung-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1867 simple-ws-beg (min (1+ rung-pos) (point-max))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1868 (point-min))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1869
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1870 ;; Remove the properties for any nested ws that might be cached.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1871 ;; Only necessary for `c-is-sws' since `c-in-sws' will be set
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1872 ;; anyway.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1873 (c-remove-is-sws (1+ next-rung-pos) simple-ws-beg)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1874 (unless (and rung-is-marked (= simple-ws-beg rung-pos))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1875 (let ((rung-end-pos (min (1+ rung-pos) (point-max))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1876 (unless (get-text-property (1- rung-end-pos) 'c-is-sws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1877 ;; Remove any `c-in-sws' property from the last char of
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1878 ;; the rung before we mark it with `c-is-sws', so that we
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1879 ;; won't connect with the remains of a broken "ladder".
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1880 (c-remove-in-sws (1- rung-end-pos) rung-end-pos))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1881 (c-put-is-sws simple-ws-beg
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1882 rung-end-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1883 (setq rung-is-marked t)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1884 (c-put-in-sws (setq simple-ws-beg (point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1885 last-put-in-sws-pos simple-ws-beg)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1886 rung-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1887 (c-put-is-sws (setq rung-pos simple-ws-beg)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1888 (1+ next-rung-pos)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1889
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1890 (c-debug-sws-msg
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1891 "c-backward-sws not caching [%s..%s] - [%s..%s] (min %s)"
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1892 (point) (1+ next-rung-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1893 simple-ws-beg (min (1+ rung-pos) (point-max))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1894 (point-min))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1895 (setq rung-pos next-rung-pos
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1896 simple-ws-beg (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1897 ))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1898
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1899 ;; Make sure that the newly marked `c-in-sws' region doesn't connect to
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1900 ;; another one before the point (which might occur when editing inside a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1901 ;; comment or macro).
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1902 (when (eq last-put-in-sws-pos (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1903 (cond ((< (point-min) last-put-in-sws-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1904 (c-debug-sws-msg
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1905 "c-backward-sws clearing at %s for cache separation"
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1906 (1- last-put-in-sws-pos))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1907 (c-remove-in-sws (1- last-put-in-sws-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1908 last-put-in-sws-pos))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1909 ((> (point-min) 1)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1910 ;; If at bob and the buffer is narrowed, we have to clear the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1911 ;; character we're standing on instead since there might be a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1912 ;; `c-in-sws' before (point-min). In this case it's necessary
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1913 ;; to clear both properties.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1914 (c-debug-sws-msg
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1915 "c-backward-sws clearing thoroughly at %s for cache separation"
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1916 last-put-in-sws-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1917 (c-remove-is-and-in-sws last-put-in-sws-pos
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1918 (1+ last-put-in-sws-pos)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1919 )))
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1920
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1921
76400
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
1922 ;; Other whitespace tools
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
1923 (defun c-partial-ws-p (beg end)
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
1924 ;; Is the region (beg end) WS, and is there WS (or BOB/EOB) next to the
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
1925 ;; region? This is a "heuristic" function. .....
79408
a29ca195b71e (c-crosses-statement-barrier-p): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 78656
diff changeset
1926 ;;
76723
a68603f8b839 Fix typo.
Alan Mackenzie <acm@muc.de>
parents: 76400
diff changeset
1927 ;; The motivation for the second bit is to check whether removing this
a68603f8b839 Fix typo.
Alan Mackenzie <acm@muc.de>
parents: 76400
diff changeset
1928 ;; region would coalesce two symbols.
76400
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
1929 ;;
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
1930 ;; FIXME!!! This function doesn't check virtual semicolons in any way. Be
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
1931 ;; careful about using this function for, e.g. AWK. (2007/3/7)
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
1932 (save-excursion
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
1933 (let ((end+1 (min (1+ end) (point-max))))
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
1934 (or (progn (goto-char (max (point-min) (1- beg)))
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
1935 (c-skip-ws-forward end)
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
1936 (eq (point) end))
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
1937 (progn (goto-char beg)
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
1938 (c-skip-ws-forward end+1)
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
1939 (eq (point) end+1))))))
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
1940
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1941 ;; A system for finding noteworthy parens before the point.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1942
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1943 (defvar c-state-cache nil)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1944 (make-variable-buffer-local 'c-state-cache)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1945 ;; The state cache used by `c-parse-state' to cut down the amount of
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1946 ;; searching. It's the result from some earlier `c-parse-state' call.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1947 ;;
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1948 ;; The use of the cached info is more effective if the next
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1949 ;; `c-parse-state' call is on a line close by the one the cached state
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1950 ;; was made at; the cache can actually slow down a little if the
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1951 ;; cached state was made very far back in the buffer. The cache is
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1952 ;; most effective if `c-parse-state' is used on each line while moving
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1953 ;; forward.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
1954
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1955 (defvar c-state-cache-start 1)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1956 (make-variable-buffer-local 'c-state-cache-start)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1957 ;; This is (point-min) when `c-state-cache' was calculated, since a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1958 ;; change of narrowing is likely to affect the parens that are visible
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1959 ;; before the point.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1960
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1961 (defvar c-state-cache-good-pos 1)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1962 (make-variable-buffer-local 'c-state-cache-good-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1963 ;; This is a position where `c-state-cache' is known to be correct.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1964 ;; It's a position inside one of the recorded unclosed parens or the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1965 ;; top level, but not further nested inside any literal or subparen
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1966 ;; that is closed before the last recorded position.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1967 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1968 ;; The exact position is chosen to try to be close to yet earlier than
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1969 ;; the position where `c-state-cache' will be called next. Right now
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1970 ;; the heuristic is to set it to the position after the last found
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1971 ;; closing paren (of any type) before the line on which
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1972 ;; `c-parse-state' was called. That is chosen primarily to work well
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1973 ;; with refontification of the current line.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1974
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1975 (defsubst c-invalidate-state-cache (pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1976 ;; Invalidate all info on `c-state-cache' that applies to the buffer
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1977 ;; at POS or higher. This is much like `c-whack-state-after', but
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1978 ;; it never changes a paren pair element into an open paren element.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1979 ;; Doing that would mean that the new open paren wouldn't have the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1980 ;; required preceding paren pair element.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1981 (while (and (or c-state-cache
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1982 (when (< pos c-state-cache-good-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1983 (setq c-state-cache-good-pos 1)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1984 nil))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1985 (let ((elem (car c-state-cache)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1986 (if (consp elem)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1987 (or (< pos (cdr elem))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1988 (when (< pos c-state-cache-good-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1989 (setq c-state-cache-good-pos (cdr elem))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1990 nil))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1991 (or (<= pos elem)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1992 (when (< pos c-state-cache-good-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1993 (setq c-state-cache-good-pos (1+ elem))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1994 nil)))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
1995 (setq c-state-cache (cdr c-state-cache))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1996
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1997 (defun c-get-fallback-start-pos (here)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1998 ;; Return the start position for building `c-state-cache' from
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
1999 ;; scratch.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2000 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2001 ;; Go back 2 bods, but ignore any bogus positions returned by
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2002 ;; beginning-of-defun (i.e. open paren in column zero).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2003 (goto-char here)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2004 (let ((cnt 2))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2005 (while (not (or (bobp) (zerop cnt)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2006 (c-beginning-of-defun-1)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2007 (if (eq (char-after) ?\{)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2008 (setq cnt (1- cnt)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2009 (point)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2010
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2011 (defun c-parse-state ()
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2012 ;; Find and record all noteworthy parens between some good point
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2013 ;; earlier in the file and point. That good point is at least the
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2014 ;; beginning of the top-level construct we are in, or the beginning
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2015 ;; of the preceding top-level construct if we aren't in one.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2016 ;;
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2017 ;; The returned value is a list of the noteworthy parens with the
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2018 ;; last one first. If an element in the list is an integer, it's
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2019 ;; the position of an open paren which has not been closed before
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2020 ;; the point. If an element is a cons, it gives the position of a
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2021 ;; closed brace paren pair; the car is the start paren position and
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2022 ;; the cdr is the position following the closing paren. Only the
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2023 ;; last closed brace paren pair before each open paren and before
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2024 ;; the point is recorded, and thus the state never contains two cons
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2025 ;; elements in succession.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2026 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2027 ;; Currently no characters which are given paren syntax with the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2028 ;; syntax-table property are recorded, i.e. angle bracket arglist
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2029 ;; parens are never present here. Note that this might change.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2030 ;;
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2031 ;; BUG: This function doesn't cope entirely well with unbalanced
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2032 ;; parens in macros. E.g. in the following case the brace before
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2033 ;; the macro isn't balanced with the one after it:
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2034 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2035 ;; {
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2036 ;; #define X {
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2037 ;; }
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2038 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2039 ;; This function might do hidden buffer changes.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2040
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2041 (save-restriction
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2042 (let* ((here (point))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2043 (here-bol (c-point 'bol))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2044 (c-macro-start (c-query-macro-start))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2045 (in-macro-start (or c-macro-start (point)))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2046 old-state last-pos brace-pair-open brace-pair-close
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2047 pos save-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2048 (c-invalidate-state-cache here)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2049
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2050 ;; If the minimum position has changed due to narrowing then we
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2051 ;; have to fix the tail of `c-state-cache' accordingly.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2052 (unless (= c-state-cache-start (point-min))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2053 (if (> (point-min) c-state-cache-start)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2054 ;; If point-min has moved forward then we just need to cut
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2055 ;; off a bit of the tail.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2056 (let ((ptr (cons nil c-state-cache)) elem)
52605
50c6e94a91cb (c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents: 52401
diff changeset
2057 (while (and (setq elem (car-safe (cdr ptr)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2058 (>= (if (consp elem) (car elem) elem)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2059 (point-min)))
52605
50c6e94a91cb (c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents: 52401
diff changeset
2060 (setq ptr (cdr ptr)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2061 (when (consp ptr)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2062 (if (eq (cdr ptr) c-state-cache)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2063 (setq c-state-cache nil
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2064 c-state-cache-good-pos 1)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2065 (setcdr ptr nil))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2066 ;; If point-min has moved backward then we drop the state
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2067 ;; completely. It's possible to do a better job here and
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2068 ;; recalculate the top only.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2069 (setq c-state-cache nil
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2070 c-state-cache-good-pos 1))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2071 (setq c-state-cache-start (point-min)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2072
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2073 ;; Get the latest position we know are directly inside the
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2074 ;; closest containing paren of the cached state.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2075 (setq last-pos (and c-state-cache
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2076 (if (consp (car c-state-cache))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2077 (cdr (car c-state-cache))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2078 (1+ (car c-state-cache)))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2079 (if (or (not last-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2080 (< last-pos c-state-cache-good-pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2081 (setq last-pos c-state-cache-good-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2082 ;; Take the opportunity to move the cached good position
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2083 ;; further down.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2084 (if (< last-pos here-bol)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2085 (setq c-state-cache-good-pos last-pos)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2086
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2087 ;; Check if `last-pos' is in a macro. If it is, and we're not
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2088 ;; in the same macro, we must discard everything on
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2089 ;; `c-state-cache' that is inside the macro before using it.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2090 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2091 (goto-char last-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2092 (when (and (c-beginning-of-macro)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2093 (/= (point) in-macro-start))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2094 (c-invalidate-state-cache (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2095 ;; Set `last-pos' again just like above except that there's
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2096 ;; no use looking at `c-state-cache-good-pos' here.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2097 (setq last-pos (if c-state-cache
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2098 (if (consp (car c-state-cache))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2099 (cdr (car c-state-cache))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2100 (1+ (car c-state-cache)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2101 1))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2102
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2103 ;; If we've moved very far from the last cached position then
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2104 ;; it's probably better to redo it from scratch, otherwise we
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2105 ;; might spend a lot of time searching from `last-pos' down to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2106 ;; here.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2107 (when (< last-pos (- here 20000))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2108 ;; First get the fallback start position. If it turns out
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2109 ;; that it's so far back that the cached state is closer then
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2110 ;; we'll keep it afterall.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2111 (setq pos (c-get-fallback-start-pos here))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2112 (if (<= pos last-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2113 (setq pos nil)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2114 (setq last-pos nil
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2115 c-state-cache nil
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2116 c-state-cache-good-pos 1)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2117
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2118 ;; Find the start position for the forward search. (Can't
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2119 ;; search in the backward direction since the point might be in
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2120 ;; some kind of literal.)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2121
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2122 (unless pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2123 (setq old-state c-state-cache)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2124
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2125 ;; There's a cached state with a containing paren. Pop off
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2126 ;; the stale containing sexps from it by going forward out of
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2127 ;; parens as far as possible.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2128 (narrow-to-region (point-min) here)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2129 (let (placeholder pair-beg)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2130 (while (and c-state-cache
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2131 (setq placeholder
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2132 (c-up-list-forward last-pos)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2133 (setq last-pos placeholder)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2134 (if (consp (car c-state-cache))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2135 (setq pair-beg (car-safe (cdr c-state-cache))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2136 c-state-cache (cdr-safe (cdr c-state-cache)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2137 (setq pair-beg (car c-state-cache)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2138 c-state-cache (cdr c-state-cache))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2139
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2140 (when (and pair-beg (eq (char-after pair-beg) ?{))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2141 ;; The last paren pair we moved out from was a brace
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2142 ;; pair. Modify the state to record this as a closed
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2143 ;; pair now.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2144 (if (consp (car-safe c-state-cache))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2145 (setq c-state-cache (cdr c-state-cache)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2146 (setq c-state-cache (cons (cons pair-beg last-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2147 c-state-cache))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2148
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2149 ;; Check if the preceding balanced paren is within a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2150 ;; macro; it should be ignored if we're outside the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2151 ;; macro. There's no need to check any further upwards;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2152 ;; if the macro contains an unbalanced opening paren then
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2153 ;; we're smoked anyway.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2154 (when (and (<= (point) in-macro-start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2155 (consp (car c-state-cache)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2156 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2157 (goto-char (car (car c-state-cache)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2158 (when (c-beginning-of-macro)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2159 (setq here (point)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2160 c-state-cache (cdr c-state-cache)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2161
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2162 (unless (eq c-state-cache old-state)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2163 ;; Have to adjust the cached good position if state has been
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2164 ;; popped off.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2165 (setq c-state-cache-good-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2166 (if c-state-cache
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2167 (if (consp (car c-state-cache))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2168 (cdr (car c-state-cache))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2169 (1+ (car c-state-cache)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2170 1)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2171 old-state c-state-cache))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2172
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2173 (when c-state-cache
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2174 (setq pos last-pos)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2175
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2176 ;; Get the fallback start position.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2177 (unless pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2178 (setq pos (c-get-fallback-start-pos here)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2179 c-state-cache nil
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2180 c-state-cache-good-pos 1))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2181
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2182 (narrow-to-region (point-min) here)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2183
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2184 (while pos
50273
ea06392567c0 (c-parse-state): Added kludge to avoid an infinite loop when Emacs'
Martin Stjernholm <mast@lysator.liu.se>
parents: 47939
diff changeset
2185 (setq save-pos pos
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2186 brace-pair-open nil)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2187
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2188 ;; Find the balanced brace pairs. This loop is hot, so it
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2189 ;; does ugly tricks to go faster.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2190 (c-safe
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2191 (let (set-good-pos set-brace-pair)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2192 (while t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2193 (setq last-pos nil
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2194 last-pos (scan-lists pos 1 -1)) ; Might signal.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2195 (setq pos (scan-lists last-pos 1 1) ; Might signal.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2196 set-good-pos (< pos here-bol)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2197 set-brace-pair (eq (char-before last-pos) ?{))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2198
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2199 ;; Update the cached good position and record the brace
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2200 ;; pair, whichever is applicable for the paren we've
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2201 ;; just jumped over. But first check that it isn't
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2202 ;; inside a macro and the point isn't inside the same
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2203 ;; one.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2204 (when (and (or set-good-pos set-brace-pair)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2205 (or (>= pos in-macro-start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2206 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2207 (goto-char pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2208 (not (c-beginning-of-macro)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2209 (if set-good-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2210 (setq c-state-cache-good-pos pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2211 (if set-brace-pair
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2212 (setq brace-pair-open last-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2213 brace-pair-close pos))))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2214
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2215 ;; Record the last brace pair.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2216 (when brace-pair-open
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2217 (let ((head (car-safe c-state-cache)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2218 (if (consp head)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2219 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2220 (setcar head (1- brace-pair-open))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2221 (setcdr head brace-pair-close))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2222 (setq c-state-cache (cons (cons (1- brace-pair-open)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2223 brace-pair-close)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2224 c-state-cache)))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2225
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2226 (if last-pos
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2227 ;; Prepare to loop, but record the open paren only if it's
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2228 ;; outside a macro or within the same macro as point, and
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2229 ;; if it is a legitimate open paren and not some character
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2230 ;; that got an open paren syntax-table property.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2231 (progn
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2232 (setq pos last-pos)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2233 (when (and (or (>= last-pos in-macro-start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2234 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2235 (goto-char last-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2236 (not (c-beginning-of-macro))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2237 ;; Check for known types of parens that we
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2238 ;; want to record. The syntax table is not to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2239 ;; be trusted here since the caller might be
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2240 ;; using e.g. `c++-template-syntax-table'.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2241 (memq (char-before last-pos) '(?{ ?\( ?\[)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2242 (if (< last-pos here-bol)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2243 (setq c-state-cache-good-pos last-pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2244 (setq c-state-cache (cons (1- last-pos) c-state-cache))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2245
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2246 (if (setq last-pos (c-up-list-forward pos))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2247 ;; Found a close paren without a corresponding opening
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2248 ;; one. Maybe we didn't go back far enough, so try to
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2249 ;; scan backward for the start paren and then start over.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2250 (progn
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2251 (setq pos (c-up-list-backward pos)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2252 c-state-cache nil
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2253 c-state-cache-good-pos c-state-cache-start)
50273
ea06392567c0 (c-parse-state): Added kludge to avoid an infinite loop when Emacs'
Martin Stjernholm <mast@lysator.liu.se>
parents: 47939
diff changeset
2254 (when (or (not pos)
ea06392567c0 (c-parse-state): Added kludge to avoid an infinite loop when Emacs'
Martin Stjernholm <mast@lysator.liu.se>
parents: 47939
diff changeset
2255 ;; Emacs (up to at least 21.2) can get confused by
ea06392567c0 (c-parse-state): Added kludge to avoid an infinite loop when Emacs'
Martin Stjernholm <mast@lysator.liu.se>
parents: 47939
diff changeset
2256 ;; open parens in column zero inside comments: The
ea06392567c0 (c-parse-state): Added kludge to avoid an infinite loop when Emacs'
Martin Stjernholm <mast@lysator.liu.se>
parents: 47939
diff changeset
2257 ;; sexp functions can then misbehave and bring us
ea06392567c0 (c-parse-state): Added kludge to avoid an infinite loop when Emacs'
Martin Stjernholm <mast@lysator.liu.se>
parents: 47939
diff changeset
2258 ;; back to the same point again. Check this so that
ea06392567c0 (c-parse-state): Added kludge to avoid an infinite loop when Emacs'
Martin Stjernholm <mast@lysator.liu.se>
parents: 47939
diff changeset
2259 ;; we don't get an infinite loop.
ea06392567c0 (c-parse-state): Added kludge to avoid an infinite loop when Emacs'
Martin Stjernholm <mast@lysator.liu.se>
parents: 47939
diff changeset
2260 (>= pos save-pos))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2261 (setq pos last-pos
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2262 c-parsing-error
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2263 (format "Unbalanced close paren at line %d"
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2264 (1+ (count-lines (point-min)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2265 (c-point 'bol last-pos)))))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2266 (setq pos nil))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2267
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2268 ;;(message "c-parse-state: %S end: %S" c-state-cache c-state-cache-good-pos)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2269 c-state-cache)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2270
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2271 ;; Debug tool to catch cache inconsistencies.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2272 (defvar c-debug-parse-state nil)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2273 (unless (fboundp 'c-real-parse-state)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2274 (fset 'c-real-parse-state (symbol-function 'c-parse-state)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2275 (cc-bytecomp-defun c-real-parse-state)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2276 (defun c-debug-parse-state ()
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2277 (let ((res1 (c-real-parse-state)) res2)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2278 (let ((c-state-cache nil)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2279 (c-state-cache-start 1)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2280 (c-state-cache-good-pos 1))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2281 (setq res2 (c-real-parse-state)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2282 (unless (equal res1 res2)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2283 ;; The cache can actually go further back due to the ad-hoc way
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2284 ;; the first paren is found, so try to whack off a bit of its
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2285 ;; start before complaining.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2286 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2287 (goto-char (or (c-least-enclosing-brace res2) (point)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2288 (c-beginning-of-defun-1)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2289 (while (not (or (bobp) (eq (char-after) ?{)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2290 (c-beginning-of-defun-1))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2291 (unless (equal (c-whack-state-before (point) res1) res2)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2292 (message (concat "c-parse-state inconsistency: "
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2293 "using cache: %s, from scratch: %s")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2294 res1 res2))))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2295 res1))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2296 (defun c-toggle-parse-state-debug (&optional arg)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2297 (interactive "P")
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2298 (setq c-debug-parse-state (c-calculate-state arg c-debug-parse-state))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2299 (fset 'c-parse-state (symbol-function (if c-debug-parse-state
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2300 'c-debug-parse-state
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2301 'c-real-parse-state)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2302 (c-keep-region-active))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2303 (when c-debug-parse-state
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2304 (c-toggle-parse-state-debug 1))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2305
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2306 (defun c-whack-state-before (bufpos paren-state)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2307 ;; Whack off any state information from PAREN-STATE which lies
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2308 ;; before BUFPOS. Not destructive on PAREN-STATE.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2309 (let* ((newstate (list nil))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2310 (ptr newstate)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2311 car)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2312 (while paren-state
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2313 (setq car (car paren-state)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2314 paren-state (cdr paren-state))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2315 (if (< (if (consp car) (car car) car) bufpos)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2316 (setq paren-state nil)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2317 (setcdr ptr (list car))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2318 (setq ptr (cdr ptr))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2319 (cdr newstate)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2320
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2321 (defun c-whack-state-after (bufpos paren-state)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2322 ;; Whack off any state information from PAREN-STATE which lies at or
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2323 ;; after BUFPOS. Not destructive on PAREN-STATE.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2324 (catch 'done
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2325 (while paren-state
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2326 (let ((car (car paren-state)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2327 (if (consp car)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2328 ;; just check the car, because in a balanced brace
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2329 ;; expression, it must be impossible for the corresponding
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2330 ;; close brace to be before point, but the open brace to
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2331 ;; be after.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2332 (if (<= bufpos (car car))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2333 nil ; whack it off
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2334 (if (< bufpos (cdr car))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2335 ;; its possible that the open brace is before
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2336 ;; bufpos, but the close brace is after. In that
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2337 ;; case, convert this to a non-cons element. The
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2338 ;; rest of the state is before bufpos, so we're
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2339 ;; done.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2340 (throw 'done (cons (car car) (cdr paren-state)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2341 ;; we know that both the open and close braces are
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2342 ;; before bufpos, so we also know that everything else
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2343 ;; on state is before bufpos.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2344 (throw 'done paren-state)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2345 (if (<= bufpos car)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2346 nil ; whack it off
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2347 ;; it's before bufpos, so everything else should too.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2348 (throw 'done paren-state)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2349 (setq paren-state (cdr paren-state)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
2350 nil)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2351
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2352 (defun c-most-enclosing-brace (paren-state &optional bufpos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2353 ;; Return the bufpos of the innermost enclosing open paren before
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2354 ;; bufpos, or nil if none was found.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2355 (let (enclosingp)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2356 (or bufpos (setq bufpos 134217727))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2357 (while paren-state
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2358 (setq enclosingp (car paren-state)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2359 paren-state (cdr paren-state))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2360 (if (or (consp enclosingp)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2361 (>= enclosingp bufpos))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2362 (setq enclosingp nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2363 (setq paren-state nil)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2364 enclosingp))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2365
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2366 (defun c-least-enclosing-brace (paren-state)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2367 ;; Return the bufpos of the outermost enclosing open paren, or nil
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2368 ;; if none was found.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2369 (let (pos elem)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2370 (while paren-state
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2371 (setq elem (car paren-state)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2372 paren-state (cdr paren-state))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2373 (if (integerp elem)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2374 (setq pos elem)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2375 pos))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2376
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2377 (defun c-safe-position (bufpos paren-state)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2378 ;; Return the closest "safe" position recorded on PAREN-STATE that
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2379 ;; is higher up than BUFPOS. Return nil if PAREN-STATE doesn't
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2380 ;; contain any. Return nil if BUFPOS is nil, which is useful to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2381 ;; find the closest limit before a given limit that might be nil.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2382 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2383 ;; A "safe" position is a position at or after a recorded open
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2384 ;; paren, or after a recorded close paren. The returned position is
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2385 ;; thus either the first position after a close brace, or the first
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2386 ;; position after an enclosing paren, or at the enclosing paren in
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2387 ;; case BUFPOS is immediately after it.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2388 (when bufpos
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2389 (let (elem)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2390 (catch 'done
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2391 (while paren-state
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2392 (setq elem (car paren-state))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2393 (if (consp elem)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2394 (cond ((< (cdr elem) bufpos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2395 (throw 'done (cdr elem)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2396 ((< (car elem) bufpos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2397 ;; See below.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2398 (throw 'done (min (1+ (car elem)) bufpos))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2399 (if (< elem bufpos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2400 ;; elem is the position at and not after the opening paren, so
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2401 ;; we can go forward one more step unless it's equal to
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2402 ;; bufpos. This is useful in some cases avoid an extra paren
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2403 ;; level between the safe position and bufpos.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2404 (throw 'done (min (1+ elem) bufpos))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2405 (setq paren-state (cdr paren-state)))))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2406
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2407 (defun c-beginning-of-syntax ()
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2408 ;; This is used for `font-lock-beginning-of-syntax-function'. It
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2409 ;; goes to the closest previous point that is known to be outside
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2410 ;; any string literal or comment. `c-state-cache' is used if it has
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2411 ;; a position in the vicinity.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2412 (let* ((paren-state c-state-cache)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2413 elem
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2414
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2415 (pos (catch 'done
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2416 ;; Note: Similar code in `c-safe-position'. The
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2417 ;; difference is that we accept a safe position at
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2418 ;; the point and don't bother to go forward past open
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2419 ;; parens.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2420 (while paren-state
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2421 (setq elem (car paren-state))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2422 (if (consp elem)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2423 (cond ((<= (cdr elem) (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2424 (throw 'done (cdr elem)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2425 ((<= (car elem) (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2426 (throw 'done (car elem))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2427 (if (<= elem (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2428 (throw 'done elem)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2429 (setq paren-state (cdr paren-state)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2430 (point-min))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2431
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2432 (if (> pos (- (point) 4000))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2433 (goto-char pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2434 ;; The position is far back. Try `c-beginning-of-defun-1'
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2435 ;; (although we can't be entirely sure it will go to a position
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2436 ;; outside a comment or string in current emacsen). FIXME:
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2437 ;; Consult `syntax-ppss' here.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2438 (c-beginning-of-defun-1)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2439 (if (< (point) pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2440 (goto-char pos)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2441
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2442
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2443 ;; Tools for scanning identifiers and other tokens.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2444
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2445 (defun c-on-identifier ()
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2446 "Return non-nil if the point is on or directly after an identifier.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2447 Keywords are recognized and not considered identifiers. If an
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2448 identifier is detected, the returned value is its starting position.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2449 If an identifier ends at the point and another begins at it \(can only
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2450 happen in Pike) then the point for the preceding one is returned.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2451
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2452 Note that this function might do hidden buffer changes. See the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2453 comment at the start of cc-engine.el for more info."
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2454
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2455 ;; FIXME: Shouldn't this function handle "operator" in C++?
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2456
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2457 (save-excursion
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2458 (skip-syntax-backward "w_")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2459
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2460 (or
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2461
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2462 ;; Check for a normal (non-keyword) identifier.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2463 (and (looking-at c-symbol-start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2464 (not (looking-at c-keywords-regexp))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2465 (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2466
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2467 (when (c-major-mode-is 'pike-mode)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2468 ;; Handle the `<operator> syntax in Pike.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2469 (let ((pos (point)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2470 (skip-chars-backward "-!%&*+/<=>^|~[]()")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2471 (and (if (< (skip-chars-backward "`") 0)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2472 t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2473 (goto-char pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2474 (eq (char-after) ?\`))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2475 (looking-at c-symbol-key)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2476 (>= (match-end 0) pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2477 (point))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2478
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2479 ;; Handle the "operator +" syntax in C++.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2480 (when (and c-overloadable-operators-regexp
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2481 (= (c-backward-token-2 0) 0))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2482
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2483 (cond ((and (looking-at c-overloadable-operators-regexp)
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
2484 (or (not c-opt-op-identifier-prefix)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2485 (and (= (c-backward-token-2 1) 0)
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
2486 (looking-at c-opt-op-identifier-prefix))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2487 (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2488
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2489 ((save-excursion
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
2490 (and c-opt-op-identifier-prefix
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
2491 (looking-at c-opt-op-identifier-prefix)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2492 (= (c-forward-token-2 1) 0)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2493 (looking-at c-overloadable-operators-regexp)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2494 (point))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2495
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2496 )))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2497
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2498 (defsubst c-simple-skip-symbol-backward ()
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2499 ;; If the point is at the end of a symbol then skip backward to the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2500 ;; beginning of it. Don't move otherwise. Return non-nil if point
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2501 ;; moved.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2502 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2503 ;; This function might do hidden buffer changes.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2504 (or (< (skip-syntax-backward "w_") 0)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2505 (and (c-major-mode-is 'pike-mode)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2506 ;; Handle the `<operator> syntax in Pike.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2507 (let ((pos (point)))
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2508 (if (and (< (skip-chars-backward "-!%&*+/<=>^|~[]()") 0)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2509 (< (skip-chars-backward "`") 0)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2510 (looking-at c-symbol-key)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2511 (>= (match-end 0) pos))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2512 t
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2513 (goto-char pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2514 nil)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2515
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2516 (defun c-beginning-of-current-token (&optional back-limit)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2517 ;; Move to the beginning of the current token. Do not move if not
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2518 ;; in the middle of one. BACK-LIMIT may be used to bound the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2519 ;; backward search; if given it's assumed to be at the boundary
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
2520 ;; between two tokens. Return non-nil if the point is moved, nil
76400
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
2521 ;; otherwise.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2522 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2523 ;; This function might do hidden buffer changes.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2524 (let ((start (point)))
76400
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
2525 (if (looking-at "\\w\\|\\s_")
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
2526 (skip-syntax-backward "w_" back-limit)
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
2527 (when (< (skip-syntax-backward ".()" back-limit) 0)
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
2528 (while (let ((pos (or (and (looking-at c-nonsymbol-token-regexp)
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
2529 (match-end 0))
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
2530 ;; `c-nonsymbol-token-regexp' should always match
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
2531 ;; since we've skipped backward over punctuator
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
2532 ;; or paren syntax, but consume one char in case
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
2533 ;; it doesn't so that we don't leave point before
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
2534 ;; some earlier incorrect token.
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
2535 (1+ (point)))))
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
2536 (if (<= pos start)
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
2537 (goto-char pos))))))
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
2538 (< (point) start)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2539
52107
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
2540 (defun c-end-of-current-token (&optional back-limit)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2541 ;; Move to the end of the current token. Do not move if not in the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2542 ;; middle of one. BACK-LIMIT may be used to bound the backward
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2543 ;; search; if given it's assumed to be at the boundary between two
52107
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
2544 ;; tokens. Return non-nil if the point is moved, nil otherwise.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2545 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2546 ;; This function might do hidden buffer changes.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2547 (let ((start (point)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2548 (cond ((< (skip-syntax-backward "w_" (1- start)) 0)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2549 (skip-syntax-forward "w_"))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2550 ((< (skip-syntax-backward ".()" back-limit) 0)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2551 (while (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2552 (if (looking-at c-nonsymbol-token-regexp)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2553 (goto-char (match-end 0))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2554 ;; `c-nonsymbol-token-regexp' should always match since
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2555 ;; we've skipped backward over punctuator or paren
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2556 ;; syntax, but move forward in case it doesn't so that
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2557 ;; we don't leave point earlier than we started with.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2558 (forward-char))
52107
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
2559 (< (point) start)))))
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
2560 (> (point) start)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2561
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2562 (defconst c-jump-syntax-balanced
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2563 (if (memq 'gen-string-delim c-emacs-features)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2564 "\\w\\|\\s_\\|\\s\(\\|\\s\)\\|\\s\"\\|\\s|"
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2565 "\\w\\|\\s_\\|\\s\(\\|\\s\)\\|\\s\""))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2566
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2567 (defconst c-jump-syntax-unbalanced
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2568 (if (memq 'gen-string-delim c-emacs-features)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2569 "\\w\\|\\s_\\|\\s\"\\|\\s|"
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2570 "\\w\\|\\s_\\|\\s\""))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2571
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2572 (defun c-forward-token-2 (&optional count balanced limit)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2573 "Move forward by tokens.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2574 A token is defined as all symbols and identifiers which aren't
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2575 syntactic whitespace \(note that multicharacter tokens like \"==\" are
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2576 treated properly). Point is always either left at the beginning of a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2577 token or not moved at all. COUNT specifies the number of tokens to
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2578 move; a negative COUNT moves in the opposite direction. A COUNT of 0
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2579 moves to the next token beginning only if not already at one. If
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2580 BALANCED is true, move over balanced parens, otherwise move into them.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2581 Also, if BALANCED is true, never move out of an enclosing paren.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2582
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2583 LIMIT sets the limit for the movement and defaults to the point limit.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2584 The case when LIMIT is set in the middle of a token, comment or macro
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2585 is handled correctly, i.e. the point won't be left there.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2586
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2587 Return the number of tokens left to move \(positive or negative). If
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2588 BALANCED is true, a move over a balanced paren counts as one. Note
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2589 that if COUNT is 0 and no appropriate token beginning is found, 1 will
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2590 be returned. Thus, a return value of 0 guarantees that point is at
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2591 the requested position and a return value less \(without signs) than
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2592 COUNT guarantees that point is at the beginning of some token.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2593
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2594 Note that this function might do hidden buffer changes. See the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2595 comment at the start of cc-engine.el for more info."
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2596
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2597 (or count (setq count 1))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2598 (if (< count 0)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2599 (- (c-backward-token-2 (- count) balanced limit))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2600
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2601 (let ((jump-syntax (if balanced
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2602 c-jump-syntax-balanced
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2603 c-jump-syntax-unbalanced))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2604 (last (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2605 (prev (point)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2606
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2607 (if (zerop count)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2608 ;; If count is zero we should jump if in the middle of a token.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2609 (c-end-of-current-token))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2610
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2611 (save-restriction
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2612 (if limit (narrow-to-region (point-min) limit))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2613 (if (/= (point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2614 (progn (c-forward-syntactic-ws) (point)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2615 ;; Skip whitespace. Count this as a move if we did in
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2616 ;; fact move.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2617 (setq count (max (1- count) 0)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2618
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2619 (if (eobp)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2620 ;; Moved out of bounds. Make sure the returned count isn't zero.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2621 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2622 (if (zerop count) (setq count 1))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2623 (goto-char last))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2624
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2625 ;; Use `condition-case' to avoid having the limit tests
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2626 ;; inside the loop.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2627 (condition-case nil
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2628 (while (and
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2629 (> count 0)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2630 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2631 (setq last (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2632 (cond ((looking-at jump-syntax)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2633 (goto-char (scan-sexps (point) 1))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2634 t)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2635 ((looking-at c-nonsymbol-token-regexp)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2636 (goto-char (match-end 0))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2637 t)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2638 ;; `c-nonsymbol-token-regexp' above should always
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2639 ;; match if there are correct tokens. Try to
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2640 ;; widen to see if the limit was set in the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2641 ;; middle of one, else fall back to treating
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2642 ;; the offending thing as a one character token.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2643 ((and limit
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2644 (save-restriction
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2645 (widen)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2646 (looking-at c-nonsymbol-token-regexp)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2647 nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2648 (t
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2649 (forward-char)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2650 t))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2651 (c-forward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2652 (setq prev last
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2653 count (1- count)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2654 (error (goto-char last)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2655
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2656 (when (eobp)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2657 (goto-char prev)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2658 (setq count (1+ count)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2659
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2660 count)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2661
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2662 (defun c-backward-token-2 (&optional count balanced limit)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2663 "Move backward by tokens.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2664 See `c-forward-token-2' for details."
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2665
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2666 (or count (setq count 1))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2667 (if (< count 0)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2668 (- (c-forward-token-2 (- count) balanced limit))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2669
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2670 (or limit (setq limit (point-min)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2671 (let ((jump-syntax (if balanced
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2672 c-jump-syntax-balanced
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2673 c-jump-syntax-unbalanced))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2674 (last (point)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2675
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2676 (if (zerop count)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2677 ;; The count is zero so try to skip to the beginning of the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2678 ;; current token.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2679 (if (> (point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2680 (progn (c-beginning-of-current-token) (point)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2681 (if (< (point) limit)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2682 ;; The limit is inside the same token, so return 1.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2683 (setq count 1))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2684
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2685 ;; We're not in the middle of a token. If there's
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2686 ;; whitespace after the point then we must move backward,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2687 ;; so set count to 1 in that case.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2688 (and (looking-at c-syntactic-ws-start)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2689 ;; If we're looking at a '#' that might start a cpp
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2690 ;; directive then we have to do a more elaborate check.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2691 (or (/= (char-after) ?#)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2692 (not c-opt-cpp-prefix)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2693 (save-excursion
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2694 (and (= (point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2695 (progn (beginning-of-line)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2696 (looking-at "[ \t]*")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2697 (match-end 0)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2698 (or (bobp)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2699 (progn (backward-char)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2700 (not (eq (char-before) ?\\)))))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2701 (setq count 1))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2702
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2703 ;; Use `condition-case' to avoid having to check for buffer
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2704 ;; limits in `backward-char', `scan-sexps' and `goto-char' below.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2705 (condition-case nil
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2706 (while (and
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2707 (> count 0)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2708 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2709 (c-backward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2710 (backward-char)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2711 (if (looking-at jump-syntax)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2712 (goto-char (scan-sexps (1+ (point)) -1))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2713 ;; This can be very inefficient if there's a long
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2714 ;; sequence of operator tokens without any separation.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2715 ;; That doesn't happen in practice, anyway.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2716 (c-beginning-of-current-token))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2717 (>= (point) limit)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2718 (setq last (point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2719 count (1- count)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2720 (error (goto-char last)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2721
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2722 (if (< (point) limit)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2723 (goto-char last))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2724
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2725 count)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2726
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2727 (defun c-forward-token-1 (&optional count balanced limit)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2728 "Like `c-forward-token-2' but doesn't treat multicharacter operator
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2729 tokens like \"==\" as single tokens, i.e. all sequences of symbol
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2730 characters are jumped over character by character. This function is
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2731 for compatibility only; it's only a wrapper over `c-forward-token-2'."
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2732 (let ((c-nonsymbol-token-regexp "\\s.\\|\\s\(\\|\\s\)"))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2733 (c-forward-token-2 count balanced limit)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2734
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2735 (defun c-backward-token-1 (&optional count balanced limit)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2736 "Like `c-backward-token-2' but doesn't treat multicharacter operator
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2737 tokens like \"==\" as single tokens, i.e. all sequences of symbol
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2738 characters are jumped over character by character. This function is
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2739 for compatibility only; it's only a wrapper over `c-backward-token-2'."
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2740 (let ((c-nonsymbol-token-regexp "\\s.\\|\\s\(\\|\\s\)"))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2741 (c-backward-token-2 count balanced limit)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2742
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2743
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2744 ;; Tools for doing searches restricted to syntactically relevant text.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2745
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2746 (defun c-syntactic-re-search-forward (regexp &optional bound noerror
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2747 paren-level not-inside-token
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2748 lookbehind-submatch)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2749 "Like `re-search-forward', but only report matches that are found
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2750 in syntactically significant text. I.e. matches in comments, macros
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2751 or string literals are ignored. The start point is assumed to be
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2752 outside any comment, macro or string literal, or else the content of
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2753 that region is taken as syntactically significant text.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2754
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2755 If PAREN-LEVEL is non-nil, an additional restriction is added to
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2756 ignore matches in nested paren sexps. The search will also not go
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2757 outside the current list sexp, which has the effect that if the point
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2758 should be moved to BOUND when no match is found \(i.e. NOERROR is
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2759 neither nil nor t), then it will be at the closing paren if the end of
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2760 the current list sexp is encountered first.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2761
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2762 If NOT-INSIDE-TOKEN is non-nil, matches in the middle of tokens are
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2763 ignored. Things like multicharacter operators and special symbols
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2764 \(e.g. \"`()\" in Pike) are handled but currently not floating point
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2765 constants.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2766
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2767 If LOOKBEHIND-SUBMATCH is non-nil, it's taken as a number of a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2768 subexpression in REGEXP. The end of that submatch is used as the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2769 position to check for syntactic significance. If LOOKBEHIND-SUBMATCH
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2770 isn't used or if that subexpression didn't match then the start
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2771 position of the whole match is used instead. The \"look behind\"
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2772 subexpression is never tested before the starting position, so it
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2773 might be a good idea to include \\=\\= as a match alternative in it.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2774
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2775 Optimization note: Matches might be missed if the \"look behind\"
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2776 subexpression can match the end of nonwhite syntactic whitespace,
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2777 i.e. the end of comments or cpp directives. This since the function
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2778 skips over such things before resuming the search. It's on the other
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2779 hand not safe to assume that the \"look behind\" subexpression never
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2780 matches syntactic whitespace.
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2781
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2782 Bug: Unbalanced parens inside cpp directives are currently not handled
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2783 correctly \(i.e. they don't get ignored as they should) when
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2784 PAREN-LEVEL is set.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2785
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2786 Note that this function might do hidden buffer changes. See the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2787 comment at the start of cc-engine.el for more info."
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2788
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2789 (or bound (setq bound (point-max)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2790 (if paren-level (setq paren-level -1))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2791
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2792 ;;(message "c-syntactic-re-search-forward %s %s %S" (point) bound regexp)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2793
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2794 (let ((start (point))
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2795 tmp
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2796 ;; Start position for the last search.
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2797 search-pos
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2798 ;; The `parse-partial-sexp' state between the start position
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2799 ;; and the point.
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2800 state
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2801 ;; The current position after the last state update. The next
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2802 ;; `parse-partial-sexp' continues from here.
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2803 (state-pos (point))
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2804 ;; The position at which to check the state and the state
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2805 ;; there. This is separate from `state-pos' since we might
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2806 ;; need to back up before doing the next search round.
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2807 check-pos check-state
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2808 ;; Last position known to end a token.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2809 (last-token-end-pos (point-min))
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2810 ;; Set when a valid match is found.
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2811 found)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2812
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2813 (condition-case err
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2814 (while
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2815 (and
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2816 (progn
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2817 (setq search-pos (point))
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2818 (re-search-forward regexp bound noerror))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2819
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2820 (progn
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2821 (setq state (parse-partial-sexp
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2822 state-pos (match-beginning 0) paren-level nil state)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2823 state-pos (point))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2824 (if (setq check-pos (and lookbehind-submatch
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2825 (or (not paren-level)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2826 (>= (car state) 0))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2827 (match-end lookbehind-submatch)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2828 (setq check-state (parse-partial-sexp
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2829 state-pos check-pos paren-level nil state))
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2830 (setq check-pos state-pos
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2831 check-state state))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2832
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2833 ;; NOTE: If we got a look behind subexpression and get
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2834 ;; an insignificant match in something that isn't
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2835 ;; syntactic whitespace (i.e. strings or in nested
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2836 ;; parentheses), then we can never skip more than a
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2837 ;; single character from the match start position
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2838 ;; (i.e. `state-pos' here) before continuing the
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2839 ;; search. That since the look behind subexpression
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2840 ;; might match the end of the insignificant region in
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2841 ;; the next search.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2842
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2843 (cond
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2844 ((elt check-state 7)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2845 ;; Match inside a line comment. Skip to eol. Use
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2846 ;; `re-search-forward' instead of `skip-chars-forward' to get
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2847 ;; the right bound behavior.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2848 (re-search-forward "[\n\r]" bound noerror))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2849
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2850 ((elt check-state 4)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2851 ;; Match inside a block comment. Skip to the '*/'.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2852 (search-forward "*/" bound noerror))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2853
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2854 ((and (not (elt check-state 5))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2855 (eq (char-before check-pos) ?/)
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2856 (not (c-get-char-property (1- check-pos) 'syntax-table))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2857 (memq (char-after check-pos) '(?/ ?*)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2858 ;; Match in the middle of the opener of a block or line
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2859 ;; comment.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2860 (if (= (char-after check-pos) ?/)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2861 (re-search-forward "[\n\r]" bound noerror)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2862 (search-forward "*/" bound noerror)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2863
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2864 ;; The last `parse-partial-sexp' above might have
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2865 ;; stopped short of the real check position if the end
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2866 ;; of the current sexp was encountered in paren-level
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2867 ;; mode. The checks above are always false in that
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2868 ;; case, and since they can do better skipping in
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2869 ;; lookbehind-submatch mode, we do them before
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2870 ;; checking the paren level.
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2871
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2872 ((and paren-level
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2873 (/= (setq tmp (car check-state)) 0))
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2874 ;; Check the paren level first since we're short of the
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2875 ;; syntactic checking position if the end of the
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2876 ;; current sexp was encountered by `parse-partial-sexp'.
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2877 (if (> tmp 0)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2878
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2879 ;; Inside a nested paren sexp.
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2880 (if lookbehind-submatch
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2881 ;; See the NOTE above.
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2882 (progn (goto-char state-pos) t)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2883 ;; Skip out of the paren quickly.
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2884 (setq state (parse-partial-sexp state-pos bound 0 nil state)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2885 state-pos (point)))
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2886
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2887 ;; Have exited the current paren sexp.
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2888 (if noerror
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2889 (progn
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2890 ;; The last `parse-partial-sexp' call above
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2891 ;; has left us just after the closing paren
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2892 ;; in this case, so we can modify the bound
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2893 ;; to leave the point at the right position
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2894 ;; upon return.
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2895 (setq bound (1- (point)))
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2896 nil)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2897 (signal 'search-failed (list regexp)))))
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2898
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2899 ((setq tmp (elt check-state 3))
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2900 ;; Match inside a string.
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2901 (if (or lookbehind-submatch
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2902 (not (integerp tmp)))
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2903 ;; See the NOTE above.
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2904 (progn (goto-char state-pos) t)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2905 ;; Skip to the end of the string before continuing.
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2906 (let ((ender (make-string 1 tmp)) (continue t))
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2907 (while (if (search-forward ender bound noerror)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2908 (progn
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2909 (setq state (parse-partial-sexp
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2910 state-pos (point) nil nil state)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2911 state-pos (point))
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2912 (elt state 3))
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2913 (setq continue nil)))
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2914 continue)))
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2915
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2916 ((save-excursion
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2917 (save-match-data
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2918 (c-beginning-of-macro start)))
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2919 ;; Match inside a macro. Skip to the end of it.
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2920 (c-end-of-macro)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2921 (cond ((<= (point) bound) t)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2922 (noerror nil)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2923 (t (signal 'search-failed (list regexp)))))
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2924
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2925 ((and not-inside-token
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2926 (or (< check-pos last-token-end-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2927 (< check-pos
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2928 (save-excursion
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2929 (goto-char check-pos)
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
2930 (save-match-data
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
2931 (c-end-of-current-token last-token-end-pos))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2932 (setq last-token-end-pos (point))))))
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2933 ;; Inside a token.
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2934 (if lookbehind-submatch
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2935 ;; See the NOTE above.
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2936 (goto-char state-pos)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2937 (goto-char (min last-token-end-pos bound))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2938
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2939 (t
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2940 ;; A real match.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2941 (setq found t)
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2942 nil)))
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2943
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2944 ;; Should loop to search again, but take care to avoid
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2945 ;; looping on the same spot.
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2946 (or (/= search-pos (point))
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2947 (if (= (point) bound)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2948 (if noerror
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2949 nil
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2950 (signal 'search-failed (list regexp)))
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2951 (forward-char)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2952 t))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2953
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2954 (error
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2955 (goto-char start)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2956 (signal (car err) (cdr err))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2957
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2958 ;;(message "c-syntactic-re-search-forward done %s" (or (match-end 0) (point)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2959
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2960 (if found
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2961 (progn
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2962 (goto-char (match-end 0))
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2963 (match-end 0))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2964
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2965 ;; Search failed. Set point as appropriate.
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2966 (if (eq noerror t)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2967 (goto-char start)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
2968 (goto-char bound))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2969 nil)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2970
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2971 (defun c-syntactic-skip-backward (skip-chars &optional limit paren-level)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2972 "Like `skip-chars-backward' but only look at syntactically relevant chars,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2973 i.e. don't stop at positions inside syntactic whitespace or string
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2974 literals. Preprocessor directives are also ignored, with the exception
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2975 of the one that the point starts within, if any. If LIMIT is given,
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2976 it's assumed to be at a syntactically relevant position.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2977
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2978 If PAREN-LEVEL is non-nil, the function won't stop in nested paren
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2979 sexps, and the search will also not go outside the current paren sexp.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2980 However, if LIMIT or the buffer limit is reached inside a nested paren
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2981 then the point will be left at the limit.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2982
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2983 Non-nil is returned if the point moved, nil otherwise.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2984
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2985 Note that this function might do hidden buffer changes. See the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2986 comment at the start of cc-engine.el for more info."
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2987
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2988 (let ((start (point))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2989 state
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2990 ;; A list of syntactically relevant positions in descending
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2991 ;; order. It's used to avoid scanning repeatedly over
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2992 ;; potentially large regions with `parse-partial-sexp' to verify
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2993 ;; each position.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2994 safe-pos-list
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2995 ;; The position at the beginning of `safe-pos-list'.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
2996 safe-pos
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2997 ;; The result from `c-beginning-of-macro' at the start position or the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2998 ;; start position itself if it isn't within a macro. Evaluated on
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
2999 ;; demand.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3000 start-macro-beg
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3001 ;; The earliest position after the current one with the same paren
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3002 ;; level. Used only when `paren-level' is set.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3003 (paren-level-pos (point)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3004
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3005 (while (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3006 (while (and
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3007 (< (skip-chars-backward skip-chars limit) 0)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3008
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3009 ;; Use `parse-partial-sexp' from a safe position down to
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3010 ;; the point to check if it's outside comments and
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3011 ;; strings.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3012 (let ((pos (point)) state-2 pps-end-pos)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3013 ;; Pick a safe position as close to the point as
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3014 ;; possible.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3015 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3016 ;; FIXME: Consult `syntax-ppss' here if our
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3017 ;; cache doesn't give a good position.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3018 (while (and safe-pos-list
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3019 (> (car safe-pos-list) (point)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3020 (setq safe-pos-list (cdr safe-pos-list)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3021 (unless (setq safe-pos (car-safe safe-pos-list))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3022 (setq safe-pos (max (or (c-safe-position
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3023 (point) (or c-state-cache
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3024 (c-parse-state)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3025 0)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3026 (point-min))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3027 safe-pos-list (list safe-pos)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3028
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3029 ;; Cache positions along the way to use if we have to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3030 ;; back up more. We cache every closing paren on the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3031 ;; same level. If the paren cache is relevant in this
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3032 ;; region then we're typically already on the same
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3033 ;; level as the target position. Note that we might
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3034 ;; cache positions after opening parens in case
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3035 ;; safe-pos is in a nested list. That's both uncommon
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3036 ;; and harmless.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3037 (while (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3038 (setq state (parse-partial-sexp
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3039 safe-pos pos 0))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3040 (< (point) pos))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3041 (setq safe-pos (point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3042 safe-pos-list (cons safe-pos safe-pos-list)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3043
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3044 (cond
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3045 ((or (elt state 3) (elt state 4))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3046 ;; Inside string or comment. Continue search at the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3047 ;; beginning of it.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3048 (goto-char (elt state 8))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3049 t)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3050
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3051 ((and paren-level
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3052 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3053 (setq state-2 (parse-partial-sexp
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3054 pos paren-level-pos -1)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3055 pps-end-pos (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3056 (/= (car state-2) 0)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3057 ;; Not at the right level.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3058
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3059 (if (and (< (car state-2) 0)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3060 ;; We stop above if we go out of a paren.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3061 ;; Now check whether it precedes or is
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3062 ;; nested in the starting sexp.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3063 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3064 (setq state-2
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3065 (parse-partial-sexp
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3066 pps-end-pos paren-level-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3067 nil nil state-2))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3068 (< (car state-2) 0)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3069
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3070 ;; We've stopped short of the starting position
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3071 ;; so the hit was inside a nested list. Go up
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3072 ;; until we are at the right level.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3073 (condition-case nil
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3074 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3075 (goto-char (scan-lists pos -1
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3076 (- (car state-2))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3077 (setq paren-level-pos (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3078 (if (and limit (>= limit paren-level-pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3079 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3080 (goto-char limit)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3081 nil)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3082 t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3083 (error
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3084 (goto-char (or limit (point-min)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3085 nil))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3086
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3087 ;; The hit was outside the list at the start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3088 ;; position. Go to the start of the list and exit.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3089 (goto-char (1+ (elt state-2 1)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3090 nil))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3091
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3092 ((c-beginning-of-macro limit)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3093 ;; Inside a macro.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3094 (if (< (point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3095 (or start-macro-beg
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3096 (setq start-macro-beg
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3097 (save-excursion
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3098 (goto-char start)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3099 (c-beginning-of-macro limit)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3100 (point)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3101 t
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3102
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3103 ;; It's inside the same macro we started in so it's
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3104 ;; a relevant match.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3105 (goto-char pos)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3106 nil)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3107
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3108 ;; If the state contains the start of the containing sexp we
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3109 ;; cache that position too, so that parse-partial-sexp in the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3110 ;; next run has a bigger chance of starting at the same level
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3111 ;; as the target position and thus will get more good safe
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3112 ;; positions into the list.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3113 (if (elt state 1)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3114 (setq safe-pos (1+ (elt state 1))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3115 safe-pos-list (cons safe-pos safe-pos-list))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3116
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3117 (> (point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3118 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3119 ;; Skip syntactic ws afterwards so that we don't stop at the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3120 ;; end of a comment if `skip-chars' is something like "^/".
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3121 (c-backward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3122 (point)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3123
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3124 ;; We might want to extend this with more useful return values in
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3125 ;; the future.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3126 (/= (point) start)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3127
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3128 ;; The following is an alternative implementation of
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3129 ;; `c-syntactic-skip-backward' that uses backward movement to keep
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3130 ;; track of the syntactic context. It turned out to be generally
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3131 ;; slower than the one above which uses forward checks from earlier
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3132 ;; safe positions.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3133 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3134 ;;(defconst c-ssb-stop-re
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3135 ;; ;; The regexp matching chars `c-syntactic-skip-backward' needs to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3136 ;; ;; stop at to avoid going into comments and literals.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3137 ;; (concat
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3138 ;; ;; Match comment end syntax and string literal syntax. Also match
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3139 ;; ;; '/' for block comment endings (not covered by comment end
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3140 ;; ;; syntax).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3141 ;; "\\s>\\|/\\|\\s\""
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3142 ;; (if (memq 'gen-string-delim c-emacs-features)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3143 ;; "\\|\\s|"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3144 ;; "")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3145 ;; (if (memq 'gen-comment-delim c-emacs-features)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3146 ;; "\\|\\s!"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3147 ;; "")))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3148 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3149 ;;(defconst c-ssb-stop-paren-re
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3150 ;; ;; Like `c-ssb-stop-re' but also stops at paren chars.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3151 ;; (concat c-ssb-stop-re "\\|\\s(\\|\\s)"))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3152 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3153 ;;(defconst c-ssb-sexp-end-re
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3154 ;; ;; Regexp matching the ending syntax of a complex sexp.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3155 ;; (concat c-string-limit-regexp "\\|\\s)"))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3156 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3157 ;;(defun c-syntactic-skip-backward (skip-chars &optional limit paren-level)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3158 ;; "Like `skip-chars-backward' but only look at syntactically relevant chars,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3159 ;;i.e. don't stop at positions inside syntactic whitespace or string
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3160 ;;literals. Preprocessor directives are also ignored. However, if the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3161 ;;point is within a comment, string literal or preprocessor directory to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3162 ;;begin with, its contents is treated as syntactically relevant chars.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3163 ;;If LIMIT is given, it limits the backward search and the point will be
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3164 ;;left there if no earlier position is found.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3165 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3166 ;;If PAREN-LEVEL is non-nil, the function won't stop in nested paren
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3167 ;;sexps, and the search will also not go outside the current paren sexp.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3168 ;;However, if LIMIT or the buffer limit is reached inside a nested paren
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3169 ;;then the point will be left at the limit.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3170 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3171 ;;Non-nil is returned if the point moved, nil otherwise.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3172 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3173 ;;Note that this function might do hidden buffer changes. See the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3174 ;;comment at the start of cc-engine.el for more info."
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3175 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3176 ;; (save-restriction
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3177 ;; (when limit
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3178 ;; (narrow-to-region limit (point-max)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3179 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3180 ;; (let ((start (point)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3181 ;; (catch 'done
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3182 ;; (while (let ((last-pos (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3183 ;; (stop-pos (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3184 ;; (skip-chars-backward skip-chars)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3185 ;; (point))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3186 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3187 ;; ;; Skip back over the same region as
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3188 ;; ;; `skip-chars-backward' above, but keep to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3189 ;; ;; syntactically relevant positions.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3190 ;; (goto-char last-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3191 ;; (while (and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3192 ;; ;; `re-search-backward' with a single char regexp
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3193 ;; ;; should be fast.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3194 ;; (re-search-backward
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3195 ;; (if paren-level c-ssb-stop-paren-re c-ssb-stop-re)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3196 ;; stop-pos 'move)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3197 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3198 ;; (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3199 ;; (cond
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3200 ;; ((looking-at "\\s(")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3201 ;; ;; `paren-level' is set and we've found the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3202 ;; ;; start of the containing paren.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3203 ;; (forward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3204 ;; (throw 'done t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3205 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3206 ;; ((looking-at c-ssb-sexp-end-re)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3207 ;; ;; We're at the end of a string literal or paren
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3208 ;; ;; sexp (if `paren-level' is set).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3209 ;; (forward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3210 ;; (condition-case nil
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3211 ;; (c-backward-sexp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3212 ;; (error
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3213 ;; (goto-char limit)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3214 ;; (throw 'done t))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3215 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3216 ;; (t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3217 ;; (forward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3218 ;; ;; At the end of some syntactic ws or possibly
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3219 ;; ;; after a plain '/' operator.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3220 ;; (let ((pos (point)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3221 ;; (c-backward-syntactic-ws)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3222 ;; (if (= pos (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3223 ;; ;; Was a plain '/' operator. Go past it.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3224 ;; (backward-char)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3225 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3226 ;; (> (point) stop-pos))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3227 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3228 ;; ;; Now the point is either at `stop-pos' or at some
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3229 ;; ;; position further back if `stop-pos' was at a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3230 ;; ;; syntactically irrelevant place.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3231 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3232 ;; ;; Skip additional syntactic ws so that we don't stop
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3233 ;; ;; at the end of a comment if `skip-chars' is
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3234 ;; ;; something like "^/".
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3235 ;; (c-backward-syntactic-ws)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3236 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3237 ;; (< (point) stop-pos))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3238 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3239 ;; ;; We might want to extend this with more useful return values
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3240 ;; ;; in the future.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3241 ;; (/= (point) start))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3242
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3243
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3244 ;; Tools for handling comments and string literals.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3245
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3246 (defun c-slow-in-literal (&optional lim detect-cpp)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3247 "Return the type of literal point is in, if any.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3248 The return value is `c' if in a C-style comment, `c++' if in a C++
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3249 style comment, `string' if in a string literal, `pound' if DETECT-CPP
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3250 is non-nil and in a preprocessor line, or nil if somewhere else.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3251 Optional LIM is used as the backward limit of the search. If omitted,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3252 or nil, `c-beginning-of-defun' is used.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3253
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3254 The last point calculated is cached if the cache is enabled, i.e. if
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3255 `c-in-literal-cache' is bound to a two element vector.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3256
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3257 Note that this function might do hidden buffer changes. See the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3258 comment at the start of cc-engine.el for more info."
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3259
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3260 (if (and (vectorp c-in-literal-cache)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3261 (= (point) (aref c-in-literal-cache 0)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3262 (aref c-in-literal-cache 1)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3263 (let ((rtn (save-excursion
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3264 (let* ((pos (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3265 (lim (or lim (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3266 (c-beginning-of-syntax)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3267 (point))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3268 (state (parse-partial-sexp lim pos)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3269 (cond
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3270 ((elt state 3) 'string)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3271 ((elt state 4) (if (elt state 7) 'c++ 'c))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3272 ((and detect-cpp (c-beginning-of-macro lim)) 'pound)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3273 (t nil))))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3274 ;; cache this result if the cache is enabled
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3275 (if (not c-in-literal-cache)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3276 (setq c-in-literal-cache (vector (point) rtn)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3277 rtn)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3278
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3279 ;; XEmacs has a built-in function that should make this much quicker.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3280 ;; I don't think we even need the cache, which makes our lives more
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3281 ;; complicated anyway. In this case, lim is only used to detect
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3282 ;; cpp directives.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3283 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3284 ;; Note that there is a bug in Xemacs's buffer-syntactic-context when used in
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3285 ;; conjunction with syntax-table-properties. The bug is present in, e.g.,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3286 ;; Xemacs 21.4.4. It manifested itself thus:
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3287 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3288 ;; Starting with an empty AWK Mode buffer, type
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3289 ;; /regexp/ {<C-j>
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3290 ;; Point gets wrongly left at column 0, rather than being indented to tab-width.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3291 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3292 ;; AWK Mode is designed such that when the first / is typed, it gets the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3293 ;; syntax-table property "string fence". When the second / is typed, BOTH /s
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3294 ;; are given the s-t property "string". However, buffer-syntactic-context
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3295 ;; fails to take account of the change of the s-t property on the opening / to
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3296 ;; "string", and reports that the { is within a string started by the second /.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3297 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3298 ;; The workaround for this is for the AWK Mode initialisation to switch the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3299 ;; defalias for c-in-literal to c-slow-in-literal. This will slow down other
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3300 ;; cc-modes in Xemacs whenever an awk-buffer has been initialised.
79408
a29ca195b71e (c-crosses-statement-barrier-p): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 78656
diff changeset
3301 ;;
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3302 ;; (Alan Mackenzie, 2003/4/30).
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3303
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3304 (defun c-fast-in-literal (&optional lim detect-cpp)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3305 ;; This function might do hidden buffer changes.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3306 (let ((context (buffer-syntactic-context)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3307 (cond
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3308 ((eq context 'string) 'string)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3309 ((eq context 'comment) 'c++)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3310 ((eq context 'block-comment) 'c)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3311 ((and detect-cpp (save-excursion (c-beginning-of-macro lim))) 'pound))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3312
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3313 (defalias 'c-in-literal
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3314 (if (fboundp 'buffer-syntactic-context)
51829
d508ffa43505 2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51714
diff changeset
3315 'c-fast-in-literal ; XEmacs
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3316 'c-slow-in-literal)) ; GNU Emacs
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3317
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3318 ;; The defalias above isn't enough to shut up the byte compiler.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3319 (cc-bytecomp-defun c-in-literal)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3320
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3321 (defun c-literal-limits (&optional lim near not-in-delimiter)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3322 "Return a cons of the beginning and end positions of the comment or
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3323 string surrounding point (including both delimiters), or nil if point
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3324 isn't in one. If LIM is non-nil, it's used as the \"safe\" position
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3325 to start parsing from. If NEAR is non-nil, then the limits of any
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3326 literal next to point is returned. \"Next to\" means there's only
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3327 spaces and tabs between point and the literal. The search for such a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3328 literal is done first in forward direction. If NOT-IN-DELIMITER is
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3329 non-nil, the case when point is inside a starting delimiter won't be
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
3330 recognized. This only has effect for comments which have starting
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3331 delimiters with more than one character.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3332
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3333 Note that this function might do hidden buffer changes. See the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3334 comment at the start of cc-engine.el for more info."
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3335
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3336 (save-excursion
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3337 (let* ((pos (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3338 (lim (or lim (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3339 (c-beginning-of-syntax)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3340 (point))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3341 (state (parse-partial-sexp lim pos)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3342
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3343 (cond ((elt state 3) ; String.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3344 (goto-char (elt state 8))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3345 (cons (point) (or (c-safe (c-forward-sexp 1) (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3346 (point-max))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3347
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3348 ((elt state 4) ; Comment.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3349 (goto-char (elt state 8))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3350 (cons (point) (progn (c-forward-single-comment) (point))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3351
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3352 ((and (not not-in-delimiter)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3353 (not (elt state 5))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3354 (eq (char-before) ?/)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3355 (looking-at "[/*]"))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3356 ;; We're standing in a comment starter.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3357 (backward-char 1)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3358 (cons (point) (progn (c-forward-single-comment) (point))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3359
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3360 (near
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3361 (goto-char pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3362
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3363 ;; Search forward for a literal.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3364 (skip-chars-forward " \t")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3365
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3366 (cond
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3367 ((looking-at c-string-limit-regexp) ; String.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3368 (cons (point) (or (c-safe (c-forward-sexp 1) (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3369 (point-max))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3370
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3371 ((looking-at c-comment-start-regexp) ; Line or block comment.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3372 (cons (point) (progn (c-forward-single-comment) (point))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3373
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3374 (t
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3375 ;; Search backward.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3376 (skip-chars-backward " \t")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3377
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3378 (let ((end (point)) beg)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3379 (cond
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3380 ((save-excursion
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3381 (< (skip-syntax-backward c-string-syntax) 0)) ; String.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3382 (setq beg (c-safe (c-backward-sexp 1) (point))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3383
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3384 ((and (c-safe (forward-char -2) t)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3385 (looking-at "*/"))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3386 ;; Block comment. Due to the nature of line
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3387 ;; comments, they will always be covered by the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3388 ;; normal case above.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3389 (goto-char end)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3390 (c-backward-single-comment)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3391 ;; If LIM is bogus, beg will be bogus.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3392 (setq beg (point))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3393
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3394 (if beg (cons beg end))))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3395 ))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3396
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3397 ;; In case external callers use this; it did have a docstring.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3398 (defalias 'c-literal-limits-fast 'c-literal-limits)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3399
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3400 (defun c-collect-line-comments (range)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3401 "If the argument is a cons of two buffer positions (such as returned by
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3402 `c-literal-limits'), and that range contains a C++ style line comment,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3403 then an extended range is returned that contains all adjacent line
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3404 comments (i.e. all comments that starts in the same column with no
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3405 empty lines or non-whitespace characters between them). Otherwise the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3406 argument is returned.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3407
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3408 Note that this function might do hidden buffer changes. See the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3409 comment at the start of cc-engine.el for more info."
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3410
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3411 (save-excursion
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3412 (condition-case nil
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3413 (if (and (consp range) (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3414 (goto-char (car range))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3415 (looking-at c-line-comment-starter)))
79408
a29ca195b71e (c-crosses-statement-barrier-p): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 78656
diff changeset
3416 (let ((col (current-column))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3417 (beg (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3418 (bopl (c-point 'bopl))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3419 (end (cdr range)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3420 ;; Got to take care in the backward direction to handle
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3421 ;; comments which are preceded by code.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3422 (while (and (c-backward-single-comment)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3423 (>= (point) bopl)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3424 (looking-at c-line-comment-starter)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3425 (= col (current-column)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3426 (setq beg (point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3427 bopl (c-point 'bopl)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3428 (goto-char end)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3429 (while (and (progn (skip-chars-forward " \t")
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3430 (looking-at c-line-comment-starter))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3431 (= col (current-column))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3432 (prog1 (zerop (forward-line 1))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3433 (setq end (point)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3434 (cons beg end))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3435 range)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3436 (error range))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3437
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3438 (defun c-literal-type (range)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3439 "Convenience function that given the result of `c-literal-limits',
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
3440 returns nil or the type of literal that the range surrounds, one
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
3441 of the symbols 'c, 'c++ or 'string. It's much faster than using
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
3442 `c-in-literal' and is intended to be used when you need both the
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
3443 type of a literal and its limits.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3444
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3445 Note that this function might do hidden buffer changes. See the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3446 comment at the start of cc-engine.el for more info."
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3447
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3448 (if (consp range)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3449 (save-excursion
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3450 (goto-char (car range))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3451 (cond ((looking-at c-string-limit-regexp) 'string)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3452 ((or (looking-at "//") ; c++ line comment
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3453 (and (looking-at "\\s<") ; comment starter
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3454 (looking-at "#"))) ; awk comment.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3455 'c++)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3456 (t 'c))) ; Assuming the range is valid.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3457 range))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3458
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3459
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3460 ;; `c-find-decl-spots' and accompanying stuff.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3461
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3462 ;; Variables used in `c-find-decl-spots' to cache the search done for
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3463 ;; the first declaration in the last call. When that function starts,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3464 ;; it needs to back up over syntactic whitespace to look at the last
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3465 ;; token before the region being searched. That can sometimes cause
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3466 ;; moves back and forth over a quite large region of comments and
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3467 ;; macros, which would be repeated for each changed character when
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3468 ;; we're called during fontification, since font-lock refontifies the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3469 ;; current line for each change. Thus it's worthwhile to cache the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3470 ;; first match.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3471 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3472 ;; `c-find-decl-syntactic-pos' is a syntactically relevant position in
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3473 ;; the syntactic whitespace less or equal to some start position.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3474 ;; There's no cached value if it's nil.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3475 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3476 ;; `c-find-decl-match-pos' is the match position if
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3477 ;; `c-find-decl-prefix-search' matched before the syntactic whitespace
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3478 ;; at `c-find-decl-syntactic-pos', or nil if there's no such match.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3479 (defvar c-find-decl-syntactic-pos nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3480 (make-variable-buffer-local 'c-find-decl-syntactic-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3481 (defvar c-find-decl-match-pos nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3482 (make-variable-buffer-local 'c-find-decl-match-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3483
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3484 (defsubst c-invalidate-find-decl-cache (change-min-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3485 (and c-find-decl-syntactic-pos
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3486 (< change-min-pos c-find-decl-syntactic-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3487 (setq c-find-decl-syntactic-pos nil)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3488
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3489 ; (defface c-debug-decl-spot-face
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3490 ; '((t (:background "Turquoise")))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3491 ; "Debug face to mark the spots where `c-find-decl-spots' stopped.")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3492 ; (defface c-debug-decl-sws-face
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3493 ; '((t (:background "Khaki")))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3494 ; "Debug face to mark the syntactic whitespace between the declaration
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3495 ; spots and the preceding token end.")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3496
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3497 (defmacro c-debug-put-decl-spot-faces (match-pos decl-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3498 (when (facep 'c-debug-decl-spot-face)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3499 `(c-save-buffer-state ((match-pos ,match-pos) (decl-pos ,decl-pos))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3500 (c-debug-add-face (max match-pos (point-min)) decl-pos
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3501 'c-debug-decl-sws-face)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3502 (c-debug-add-face decl-pos (min (1+ decl-pos) (point-max))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3503 'c-debug-decl-spot-face))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3504 (defmacro c-debug-remove-decl-spot-faces (beg end)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3505 (when (facep 'c-debug-decl-spot-face)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3506 `(c-save-buffer-state ()
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3507 (c-debug-remove-face ,beg ,end 'c-debug-decl-spot-face)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3508 (c-debug-remove-face ,beg ,end 'c-debug-decl-sws-face))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3509
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3510 (defmacro c-find-decl-prefix-search ()
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3511 ;; Macro used inside `c-find-decl-spots'. It ought to be a defun,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3512 ;; but it contains lots of free variables that refer to things
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3513 ;; inside `c-find-decl-spots'. The point is left at `cfd-match-pos'
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3514 ;; if there is a match, otherwise at `cfd-limit'.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3515 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3516 ;; This macro might do hidden buffer changes.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3517
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3518 '(progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3519 ;; Find the next property match position if we haven't got one already.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3520 (unless cfd-prop-match
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3521 (save-excursion
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3522 (while (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3523 (goto-char (next-single-property-change
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3524 (point) 'c-type nil cfd-limit))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3525 (and (< (point) cfd-limit)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3526 (not (eq (c-get-char-property (1- (point)) 'c-type)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3527 'c-decl-end)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3528 (setq cfd-prop-match (point))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3529
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3530 ;; Find the next `c-decl-prefix-or-start-re' match if we haven't
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3531 ;; got one already.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3532 (unless cfd-re-match
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3533
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3534 (if (> cfd-re-match-end (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3535 (goto-char cfd-re-match-end))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3536
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3537 (while (if (setq cfd-re-match-end
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3538 (re-search-forward c-decl-prefix-or-start-re
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3539 cfd-limit 'move))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3540
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3541 ;; Match. Check if it's inside a comment or string literal.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3542 (c-got-face-at
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3543 (if (setq cfd-re-match (match-end 1))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3544 ;; Matched the end of a token preceding a decl spot.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3545 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3546 (goto-char cfd-re-match)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3547 (1- cfd-re-match))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3548 ;; Matched a token that start a decl spot.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3549 (goto-char (match-beginning 0))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3550 (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3551 c-literal-faces)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3552
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3553 ;; No match. Finish up and exit the loop.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3554 (setq cfd-re-match cfd-limit)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3555 nil)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3556
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3557 ;; Skip out of comments and string literals.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3558 (while (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3559 (goto-char (next-single-property-change
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3560 (point) 'face nil cfd-limit))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3561 (and (< (point) cfd-limit)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3562 (c-got-face-at (point) c-literal-faces)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3563
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3564 ;; If we matched at the decl start, we have to back up over the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3565 ;; preceding syntactic ws to set `cfd-match-pos' and to catch
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3566 ;; any decl spots in the syntactic ws.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3567 (unless cfd-re-match
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3568 (c-backward-syntactic-ws)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3569 (setq cfd-re-match (point))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3570
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3571 ;; Choose whichever match is closer to the start.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3572 (if (< cfd-re-match cfd-prop-match)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3573 (setq cfd-match-pos cfd-re-match
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3574 cfd-re-match nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3575 (setq cfd-match-pos cfd-prop-match
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3576 cfd-prop-match nil))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3577
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3578 (goto-char cfd-match-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3579
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3580 (when (< cfd-match-pos cfd-limit)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3581 ;; Skip forward past comments only so we don't skip macros.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3582 (c-forward-comments)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3583 ;; Set the position to continue at. We can avoid going over
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3584 ;; the comments skipped above a second time, but it's possible
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3585 ;; that the comment skipping has taken us past `cfd-prop-match'
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3586 ;; since the property might be used inside comments.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3587 (setq cfd-continue-pos (if cfd-prop-match
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3588 (min cfd-prop-match (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3589 (point))))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3590
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3591 (defun c-find-decl-spots (cfd-limit cfd-decl-re cfd-face-checklist cfd-fun)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3592 ;; Call CFD-FUN for each possible spot for a declaration, cast or
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
3593 ;; label from the point to CFD-LIMIT.
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
3594 ;;
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
3595 ;; CFD-FUN is called with point at the start of the spot. It's
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
3596 ;; passed two arguments: The first is the end position of the token
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
3597 ;; preceding the spot, or 0 for the implicit match at bob. The
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
3598 ;; second is a flag that is t when the match is inside a macro. If
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
3599 ;; CFD-FUN adds `c-decl-end' properties somewhere below the current
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
3600 ;; spot, it should return non-nil to ensure that the next search
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
3601 ;; will find them.
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
3602 ;;
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
3603 ;; Such a spot is:
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3604 ;; o The first token after bob.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3605 ;; o The first token after the end of submatch 1 in
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3606 ;; `c-decl-prefix-or-start-re' when that submatch matches.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3607 ;; o The start of each `c-decl-prefix-or-start-re' match when
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3608 ;; submatch 1 doesn't match.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3609 ;; o The first token after the end of each occurence of the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3610 ;; `c-type' text property with the value `c-decl-end', provided
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3611 ;; `c-type-decl-end-used' is set.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3612 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3613 ;; Only a spot that match CFD-DECL-RE and whose face is in the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3614 ;; CFD-FACE-CHECKLIST list causes CFD-FUN to be called. The face
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3615 ;; check is disabled if CFD-FACE-CHECKLIST is nil.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3616 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3617 ;; If the match is inside a macro then the buffer is narrowed to the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3618 ;; end of it, so that CFD-FUN can investigate the following tokens
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3619 ;; without matching something that begins inside a macro and ends
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3620 ;; outside it. It's to avoid this work that the CFD-DECL-RE and
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3621 ;; CFD-FACE-CHECKLIST checks exist.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3622 ;;
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3623 ;; The spots are visited approximately in order from top to bottom.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3624 ;; It's however the positions where `c-decl-prefix-or-start-re'
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3625 ;; matches and where `c-decl-end' properties are found that are in
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3626 ;; order. Since the spots often are at the following token, they
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3627 ;; might be visited out of order insofar as more spots are reported
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3628 ;; later on within the syntactic whitespace between the match
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3629 ;; positions and their spots.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3630 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3631 ;; It's assumed that comments and strings are fontified in the
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3632 ;; searched range.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3633 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3634 ;; This is mainly used in fontification, and so has an elaborate
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3635 ;; cache to handle repeated calls from the same start position; see
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3636 ;; the variables above.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3637 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3638 ;; All variables in this function begin with `cfd-' to avoid name
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3639 ;; collision with the (dynamically bound) variables used in CFD-FUN.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3640 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3641 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3642
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3643 (let ((cfd-start-pos (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3644 (cfd-buffer-end (point-max))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3645 ;; The end of the token preceding the decl spot last found
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3646 ;; with `c-decl-prefix-or-start-re'. `cfd-limit' if there's
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3647 ;; no match.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3648 cfd-re-match
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3649 ;; The end position of the last `c-decl-prefix-or-start-re'
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3650 ;; match. If this is greater than `cfd-continue-pos', the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3651 ;; next regexp search is started here instead.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3652 (cfd-re-match-end (point-min))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3653 ;; The end of the last `c-decl-end' found by
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3654 ;; `c-find-decl-prefix-search'. `cfd-limit' if there's no
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3655 ;; match. If searching for the property isn't needed then we
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3656 ;; disable it by setting it to `cfd-limit' directly.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3657 (cfd-prop-match (unless c-type-decl-end-used cfd-limit))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3658 ;; The end of the token preceding the decl spot last found by
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3659 ;; `c-find-decl-prefix-search'. 0 for the implicit match at
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3660 ;; bob. `cfd-limit' if there's no match. In other words,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3661 ;; this is the minimum of `cfd-re-match' and `cfd-prop-match'.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3662 (cfd-match-pos cfd-limit)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3663 ;; The position to continue searching at.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3664 cfd-continue-pos
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3665 ;; The position of the last "real" token we've stopped at.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3666 ;; This can be greater than `cfd-continue-pos' when we get
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3667 ;; hits inside macros or at `c-decl-end' positions inside
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3668 ;; comments.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3669 (cfd-token-pos 0)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3670 ;; The end position of the last entered macro.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3671 (cfd-macro-end 0))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3672
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3673 ;; Initialize by finding a syntactically relevant start position
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3674 ;; before the point, and do the first `c-decl-prefix-or-start-re'
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3675 ;; search unless we're at bob.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3676
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3677 (let (start-in-literal start-in-macro syntactic-pos)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3678 ;; Must back up a bit since we look for the end of the previous
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3679 ;; statement or declaration, which is earlier than the first
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3680 ;; returned match.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3681
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3682 (cond
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3683 ;; First we need to move to a syntactically relevant position.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3684 ;; Begin by backing out of comment or string literals.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3685 ((and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3686 (when (c-got-face-at (point) c-literal-faces)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3687 ;; Try to use the faces to back up to the start of the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3688 ;; literal. FIXME: What if the point is on a declaration
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3689 ;; inside a comment?
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3690 (while (and (not (bobp))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3691 (c-got-face-at (1- (point)) c-literal-faces))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3692 (goto-char (previous-single-property-change
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3693 (point) 'face nil (point-min))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3694
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3695 ;; XEmacs doesn't fontify the quotes surrounding string
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3696 ;; literals.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3697 (and (featurep 'xemacs)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3698 (eq (get-text-property (point) 'face)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3699 'font-lock-string-face)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3700 (not (bobp))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3701 (progn (backward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3702 (not (looking-at c-string-limit-regexp)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3703 (forward-char))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3704
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3705 ;; Don't trust the literal to contain only literal faces
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3706 ;; (the font lock package might not have fontified the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3707 ;; start of it at all, for instance) so check that we have
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3708 ;; arrived at something that looks like a start or else
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3709 ;; resort to `c-literal-limits'.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3710 (unless (looking-at c-literal-start-regexp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3711 (let ((range (c-literal-limits)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3712 (if range (goto-char (car range)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3713
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3714 (setq start-in-literal (point)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3715
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3716 ;; The start is in a literal. If the limit is in the same
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3717 ;; one we don't have to find a syntactic position etc. We
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3718 ;; only check that if the limit is at or before bonl to save
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3719 ;; time; it covers the by far most common case when font-lock
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3720 ;; refontifies the current line only.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3721 (<= cfd-limit (c-point 'bonl cfd-start-pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3722 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3723 (goto-char cfd-start-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3724 (while (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3725 (goto-char (next-single-property-change
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3726 (point) 'face nil cfd-limit))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3727 (and (< (point) cfd-limit)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3728 (c-got-face-at (point) c-literal-faces))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3729 (= (point) cfd-limit)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3730
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3731 ;; Completely inside a literal. Set up variables to trig the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3732 ;; (< cfd-continue-pos cfd-start-pos) case below and it'll
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3733 ;; find a suitable start position.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3734 (setq cfd-continue-pos start-in-literal))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3735
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3736 ;; Check if the region might be completely inside a macro, to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3737 ;; optimize that like the completely-inside-literal above.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3738 ((save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3739 (and (= (forward-line 1) 0)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3740 (bolp) ; forward-line has funny behavior at eob.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3741 (>= (point) cfd-limit)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3742 (progn (backward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3743 (eq (char-before) ?\\))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3744 ;; (Maybe) completely inside a macro. Only need to trig the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3745 ;; (< cfd-continue-pos cfd-start-pos) case below to make it
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3746 ;; set things up.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3747 (setq cfd-continue-pos (1- cfd-start-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3748 start-in-macro t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3749
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3750 (t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3751 ;; Back out of any macro so we don't miss any declaration
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3752 ;; that could follow after it.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3753 (when (c-beginning-of-macro)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3754 (setq start-in-macro t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3755
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3756 ;; Now we're at a proper syntactically relevant position so we
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3757 ;; can use the cache. But first clear it if it applied
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3758 ;; further down.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3759 (c-invalidate-find-decl-cache cfd-start-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3760
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3761 (setq syntactic-pos (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3762 (unless (eq syntactic-pos c-find-decl-syntactic-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3763 ;; Don't have to do this if the cache is relevant here,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3764 ;; typically if the same line is refontified again. If
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3765 ;; we're just some syntactic whitespace further down we can
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3766 ;; still use the cache to limit the skipping.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3767 (c-backward-syntactic-ws c-find-decl-syntactic-pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3768
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3769 ;; If we hit `c-find-decl-syntactic-pos' and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3770 ;; `c-find-decl-match-pos' is set then we install the cached
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3771 ;; values. If we hit `c-find-decl-syntactic-pos' and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3772 ;; `c-find-decl-match-pos' is nil then we know there's no decl
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3773 ;; prefix in the whitespace before `c-find-decl-syntactic-pos'
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3774 ;; and so we can continue the search from this point. If we
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3775 ;; didn't hit `c-find-decl-syntactic-pos' then we're now in
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3776 ;; the right spot to begin searching anyway.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3777 (if (and (eq (point) c-find-decl-syntactic-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3778 c-find-decl-match-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3779 (setq cfd-match-pos c-find-decl-match-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3780 cfd-continue-pos syntactic-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3781
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3782 (setq c-find-decl-syntactic-pos syntactic-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3783
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3784 (when (if (bobp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3785 ;; Always consider bob a match to get the first
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3786 ;; declaration in the file. Do this separately instead of
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3787 ;; letting `c-decl-prefix-or-start-re' match bob, so that
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3788 ;; regexp always can consume at least one character to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3789 ;; ensure that we won't get stuck in an infinite loop.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3790 (setq cfd-re-match 0)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3791 (backward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3792 (c-beginning-of-current-token)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3793 (< (point) cfd-limit))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3794 ;; Do an initial search now. In the bob case above it's
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3795 ;; only done to search for a `c-decl-end' spot.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3796 (c-find-decl-prefix-search))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3797
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3798 (setq c-find-decl-match-pos (and (< cfd-match-pos cfd-start-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3799 cfd-match-pos)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3800
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3801 ;; Advance `cfd-continue-pos' if it's before the start position.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3802 ;; The closest continue position that might have effect at or
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3803 ;; after the start depends on what we started in. This also
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3804 ;; finds a suitable start position in the special cases when the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3805 ;; region is completely within a literal or macro.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3806 (when (and cfd-continue-pos (< cfd-continue-pos cfd-start-pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3807
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3808 (cond
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3809 (start-in-macro
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3810 ;; If we're in a macro then it's the closest preceding token
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3811 ;; in the macro. Check this before `start-in-literal',
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3812 ;; since if we're inside a literal in a macro, the preceding
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3813 ;; token is earlier than any `c-decl-end' spot inside the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3814 ;; literal (comment).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3815 (goto-char (or start-in-literal cfd-start-pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3816 ;; The only syntactic ws in macros are comments.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3817 (c-backward-comments)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3818 (backward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3819 (c-beginning-of-current-token))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3820
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3821 (start-in-literal
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3822 ;; If we're in a comment it can only be the closest
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3823 ;; preceding `c-decl-end' position within that comment, if
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3824 ;; any. Go back to the beginning of such a property so that
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3825 ;; `c-find-decl-prefix-search' will find the end of it.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3826 ;; (Can't stop at the end and install it directly on
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3827 ;; `cfd-prop-match' since that variable might be cleared
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3828 ;; after `cfd-fun' below.)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3829 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3830 ;; Note that if the literal is a string then the property
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3831 ;; search will simply skip to the beginning of it right
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3832 ;; away.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3833 (if (not c-type-decl-end-used)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3834 (goto-char start-in-literal)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3835 (goto-char cfd-start-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3836 (while (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3837 (goto-char (previous-single-property-change
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3838 (point) 'c-type nil start-in-literal))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3839 (and (> (point) start-in-literal)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3840 (not (eq (c-get-char-property (point) 'c-type)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3841 'c-decl-end))))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3842
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3843 (when (= (point) start-in-literal)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3844 ;; Didn't find any property inside the comment, so we can
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3845 ;; skip it entirely. (This won't skip past a string, but
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3846 ;; that'll be handled quickly by the next
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3847 ;; `c-find-decl-prefix-search' anyway.)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3848 (c-forward-single-comment)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3849 (if (> (point) cfd-limit)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3850 (goto-char cfd-limit))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3851
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3852 (t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3853 ;; If we started in normal code, the only match that might
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3854 ;; apply before the start is what we already got in
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3855 ;; `cfd-match-pos' so we can continue at the start position.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3856 ;; (Note that we don't get here if the first match is below
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3857 ;; it.)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3858 (goto-char cfd-start-pos)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3859
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3860 ;; Delete found matches if they are before our new continue
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3861 ;; position, so that `c-find-decl-prefix-search' won't back up
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3862 ;; to them later on.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3863 (setq cfd-continue-pos (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3864 (when (and cfd-re-match (< cfd-re-match cfd-continue-pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3865 (setq cfd-re-match nil))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3866 (when (and cfd-prop-match (< cfd-prop-match cfd-continue-pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3867 (setq cfd-prop-match nil)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3868
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3869 (if syntactic-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3870 ;; This is the normal case and we got a proper syntactic
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3871 ;; position. If there's a match then it's always outside
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3872 ;; macros and comments, so advance to the next token and set
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3873 ;; `cfd-token-pos'. The loop below will later go back using
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3874 ;; `cfd-continue-pos' to fix declarations inside the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3875 ;; syntactic ws.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3876 (when (and cfd-match-pos (< cfd-match-pos syntactic-pos))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3877 (goto-char syntactic-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3878 (c-forward-syntactic-ws)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3879 (and cfd-continue-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3880 (< cfd-continue-pos (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3881 (setq cfd-token-pos (point))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3882
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3883 ;; Have one of the special cases when the region is completely
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3884 ;; within a literal or macro. `cfd-continue-pos' is set to a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3885 ;; good start position for the search, so do it.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3886 (c-find-decl-prefix-search)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3887
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
3888 ;; Now loop. Round what? (ACM, 2006/7/5). We already got the first match.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3889
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3890 (while (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3891 (while (and
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3892 (< cfd-match-pos cfd-limit)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3893
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3894 (or
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3895 ;; Kludge to filter out matches on the "<" that
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3896 ;; aren't open parens, for the sake of languages
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3897 ;; that got `c-recognize-<>-arglists' set.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3898 (and (eq (char-before cfd-match-pos) ?<)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3899 (not (c-get-char-property (1- cfd-match-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3900 'syntax-table)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3901
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3902 ;; If `cfd-continue-pos' is less or equal to
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3903 ;; `cfd-token-pos', we've got a hit inside a macro
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3904 ;; that's in the syntactic whitespace before the last
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3905 ;; "real" declaration we've checked. If they're equal
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3906 ;; we've arrived at the declaration a second time, so
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3907 ;; there's nothing to do.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3908 (= cfd-continue-pos cfd-token-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3909
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3910 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3911 ;; If `cfd-continue-pos' is less than `cfd-token-pos'
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3912 ;; we're still searching for declarations embedded in
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3913 ;; the syntactic whitespace. In that case we need
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3914 ;; only to skip comments and not macros, since they
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3915 ;; can't be nested, and that's already been done in
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3916 ;; `c-find-decl-prefix-search'.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3917 (when (> cfd-continue-pos cfd-token-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3918 (c-forward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3919 (setq cfd-token-pos (point)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3920
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3921 ;; Continue if the following token fails the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3922 ;; CFD-DECL-RE and CFD-FACE-CHECKLIST checks.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3923 (when (or (>= (point) cfd-limit)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3924 (not (looking-at cfd-decl-re))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3925 (and cfd-face-checklist
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3926 (not (c-got-face-at
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3927 (point) cfd-face-checklist))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3928 (goto-char cfd-continue-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3929 t)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3930
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3931 (< (point) cfd-limit))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3932 (c-find-decl-prefix-search))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3933
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3934 (< (point) cfd-limit))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3935
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3936 (when (and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3937 (>= (point) cfd-start-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3938
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3939 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3940 ;; Narrow to the end of the macro if we got a hit inside
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3941 ;; one, to avoid recognizing things that start inside the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3942 ;; macro and end outside it.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3943 (when (> cfd-match-pos cfd-macro-end)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3944 ;; Not in the same macro as in the previous round.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3945 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3946 (goto-char cfd-match-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3947 (setq cfd-macro-end
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3948 (if (save-excursion (and (c-beginning-of-macro)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3949 (< (point) cfd-match-pos)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3950 (progn (c-end-of-macro)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3951 (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3952 0))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3953
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3954 (if (zerop cfd-macro-end)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3955 t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3956 (if (> cfd-macro-end (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3957 (progn (narrow-to-region (point-min) cfd-macro-end)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3958 t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3959 ;; The matched token was the last thing in the macro,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3960 ;; so the whole match is bogus.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3961 (setq cfd-macro-end 0)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3962 nil))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3963
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3964 (c-debug-put-decl-spot-faces cfd-match-pos (point))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3965 (if (funcall cfd-fun cfd-match-pos (/= cfd-macro-end 0))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3966 (setq cfd-prop-match nil))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3967
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3968 (when (/= cfd-macro-end 0)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3969 ;; Restore limits if we did macro narrowment above.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3970 (narrow-to-region (point-min) cfd-buffer-end)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3971
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3972 (goto-char cfd-continue-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3973 (if (= cfd-continue-pos cfd-limit)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3974 (setq cfd-match-pos cfd-limit)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3975 (c-find-decl-prefix-search)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3976
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3977
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3978 ;; A cache for found types.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3979
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3980 ;; Buffer local variable that contains an obarray with the types we've
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3981 ;; found. If a declaration is recognized somewhere we record the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3982 ;; fully qualified identifier in it to recognize it as a type
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3983 ;; elsewhere in the file too. This is not accurate since we do not
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3984 ;; bother with the scoping rules of the languages, but in practice the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3985 ;; same name is seldom used as both a type and something else in a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
3986 ;; file, and we only use this as a last resort in ambiguous cases (see
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3987 ;; `c-forward-decl-or-cast-1').
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3988 ;;
76400
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
3989 ;; Not every type need be in this cache. However, things which have
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
3990 ;; ceased to be types must be removed from it.
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
3991 ;;
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3992 ;; Template types in C++ are added here too but with the template
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3993 ;; arglist replaced with "<>" in references or "<" for the one in the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3994 ;; primary type. E.g. the type "Foo<A,B>::Bar<C>" is stored as
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3995 ;; "Foo<>::Bar<". This avoids storing very long strings (since C++
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3996 ;; template specs can be fairly sized programs in themselves) and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3997 ;; improves the hit ratio (it's a type regardless of the template
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3998 ;; args; it's just not the same type, but we're only interested in
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
3999 ;; recognizing types, not telling distinct types apart). Note that
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4000 ;; template types in references are added here too; from the example
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4001 ;; above there will also be an entry "Foo<".
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4002 (defvar c-found-types nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4003 (make-variable-buffer-local 'c-found-types)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4004
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4005 (defsubst c-clear-found-types ()
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4006 ;; Clears `c-found-types'.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4007 (setq c-found-types (make-vector 53 0)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4008
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4009 (defun c-add-type (from to)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4010 ;; Add the given region as a type in `c-found-types'. If the region
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4011 ;; doesn't match an existing type but there is a type which is equal
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4012 ;; to the given one except that the last character is missing, then
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4013 ;; the shorter type is removed. That's done to avoid adding all
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4014 ;; prefixes of a type as it's being entered and font locked. This
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4015 ;; doesn't cover cases like when characters are removed from a type
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4016 ;; or added in the middle. We'd need the position of point when the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4017 ;; font locking is invoked to solve this well.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4018 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4019 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4020 (let ((type (c-syntactic-content from to c-recognize-<>-arglists)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4021 (unless (intern-soft type c-found-types)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4022 (unintern (substring type 0 -1) c-found-types)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4023 (intern type c-found-types))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4024
76400
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4025 (defun c-unfind-type (name)
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4026 ;; Remove the "NAME" from c-found-types, if present.
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4027 (unintern name c-found-types))
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4028
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4029 (defsubst c-check-type (from to)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4030 ;; Return non-nil if the given region contains a type in
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4031 ;; `c-found-types'.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4032 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4033 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4034 (intern-soft (c-syntactic-content from to c-recognize-<>-arglists)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4035 c-found-types))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4036
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4037 (defun c-list-found-types ()
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4038 ;; Return all the types in `c-found-types' as a sorted list of
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4039 ;; strings.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4040 (let (type-list)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4041 (mapatoms (lambda (type)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4042 (setq type-list (cons (symbol-name type)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4043 type-list)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4044 c-found-types)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4045 (sort type-list 'string-lessp)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4046
85503
59ee4068f60b * progmodes/gud.el (gud-target-name): Move definition before use.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78656
diff changeset
4047 ;; Shut up the byte compiler.
59ee4068f60b * progmodes/gud.el (gud-target-name): Move definition before use.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78656
diff changeset
4048 (defvar c-maybe-stale-found-type)
59ee4068f60b * progmodes/gud.el (gud-target-name): Move definition before use.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78656
diff changeset
4049
76400
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4050 (defun c-trim-found-types (beg end old-len)
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4051 ;; An after change function which, in conjunction with the info in
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4052 ;; c-maybe-stale-found-type (set in c-before-change), removes a type
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4053 ;; from `c-found-types', should this type have become stale. For
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4054 ;; example, this happens to "foo" when "foo \n bar();" becomes
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4055 ;; "foo(); \n bar();". Such stale types, if not removed, foul up
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4056 ;; the fontification.
79408
a29ca195b71e (c-crosses-statement-barrier-p): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 78656
diff changeset
4057 ;;
76400
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4058 ;; Have we, perhaps, added non-ws characters to the front/back of a found
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4059 ;; type?
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4060 (when (> end beg)
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4061 (save-excursion
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4062 (when (< end (point-max))
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4063 (goto-char end)
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4064 (if (and (c-beginning-of-current-token) ; only moves when we started in the middle
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4065 (progn (goto-char end)
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4066 (c-end-of-current-token)))
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4067 (c-unfind-type (buffer-substring-no-properties
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4068 end (point)))))
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4069 (when (> beg (point-min))
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4070 (goto-char beg)
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4071 (if (and (c-end-of-current-token) ; only moves when we started in the middle
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4072 (progn (goto-char beg)
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4073 (c-beginning-of-current-token)))
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4074 (c-unfind-type (buffer-substring-no-properties
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4075 (point) beg))))))
79408
a29ca195b71e (c-crosses-statement-barrier-p): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 78656
diff changeset
4076
76400
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4077 (if c-maybe-stale-found-type ; e.g. (c-decl-id-start "foo" 97 107 " (* ooka) " "o")
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4078 (cond
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4079 ;; Changing the amount of (already existing) whitespace - don't do anything.
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4080 ((and (c-partial-ws-p beg end)
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4081 (or (= beg end) ; removal of WS
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4082 (string-match "^[ \t\n\r\f\v]*$" (nth 5 c-maybe-stale-found-type)))))
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4083
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4084 ;; The syntactic relationship which defined a "found type" has been
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4085 ;; destroyed.
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4086 ((eq (car c-maybe-stale-found-type) 'c-decl-id-start)
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4087 (c-unfind-type (cadr c-maybe-stale-found-type)))
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4088 ;; ((eq (car c-maybe-stale-found-type) 'c-decl-type-start) FIXME!!!
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4089 )))
4dc5b2641221 (c-partial-ws-p, c-unfind-type, c-trim-found-types): new functions.
Alan Mackenzie <acm@muc.de>
parents: 75623
diff changeset
4090
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4091
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4092 ;; Handling of small scale constructs like types and names.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4093
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4094 (defun c-after-change-check-<>-operators (beg end)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4095 ;; This is called from `after-change-functions' when
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4096 ;; c-recognize-<>-arglists' is set. It ensures that no "<" or ">"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4097 ;; chars with paren syntax become part of another operator like "<<"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4098 ;; or ">=".
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4099 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4100 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4101
69140
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
4102 (save-excursion
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
4103 (goto-char beg)
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
4104 (when (or (looking-at "[<>]")
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
4105 (< (skip-chars-backward "<>") 0))
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
4106
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4107 (goto-char beg)
69140
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
4108 (c-beginning-of-current-token)
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
4109 (when (and (< (point) beg)
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
4110 (looking-at c-<>-multichar-token-regexp)
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
4111 (< beg (setq beg (match-end 0))))
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
4112 (while (progn (skip-chars-forward "^<>" beg)
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
4113 (< (point) beg))
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
4114 (c-clear-char-property (point) 'syntax-table)
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
4115 (forward-char))))
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
4116
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
4117 (when (< beg end)
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
4118 (goto-char end)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4119 (when (or (looking-at "[<>]")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4120 (< (skip-chars-backward "<>") 0))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4121
69140
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
4122 (goto-char end)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4123 (c-beginning-of-current-token)
69140
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
4124 (when (and (< (point) end)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4125 (looking-at c-<>-multichar-token-regexp)
69140
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
4126 (< end (setq end (match-end 0))))
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
4127 (while (progn (skip-chars-forward "^<>" end)
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
4128 (< (point) end))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4129 (c-clear-char-property (point) 'syntax-table)
69140
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
4130 (forward-char)))))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4131
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4132 ;; Dynamically bound variable that instructs `c-forward-type' to also
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4133 ;; treat possible types (i.e. those that it normally returns 'maybe or
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4134 ;; 'found for) as actual types (and always return 'found for them).
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4135 ;; This means that it records them in `c-record-type-identifiers' if
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4136 ;; that is set, and that it adds them to `c-found-types'.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4137 (defvar c-promote-possible-types nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4138
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4139 ;; Dynamically bound variable that instructs `c-forward-<>-arglist' to
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4140 ;; mark up successfully parsed arglists with paren syntax properties on
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4141 ;; the surrounding angle brackets and with `c-<>-arg-sep' in the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4142 ;; `c-type' property of each argument separating comma.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4143 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4144 ;; Setting this variable also makes `c-forward-<>-arglist' recurse into
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4145 ;; all arglists for side effects (i.e. recording types), otherwise it
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4146 ;; exploits any existing paren syntax properties to quickly jump to the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4147 ;; end of already parsed arglists.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4148 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4149 ;; Marking up the arglists is not the default since doing that correctly
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4150 ;; depends on a proper value for `c-restricted-<>-arglists'.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4151 (defvar c-parse-and-markup-<>-arglists nil)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4152
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4153 ;; Dynamically bound variable that instructs `c-forward-<>-arglist' to
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4154 ;; not accept arglists that contain binary operators.
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4155 ;;
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4156 ;; This is primarily used to handle C++ template arglists. C++
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4157 ;; disambiguates them by checking whether the preceding name is a
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4158 ;; template or not. We can't do that, so we assume it is a template
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4159 ;; if it can be parsed as one. That usually works well since
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4160 ;; comparison expressions on the forms "a < b > c" or "a < b, c > d"
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4161 ;; in almost all cases would be pointless.
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4162 ;;
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4163 ;; However, in function arglists, e.g. in "foo (a < b, c > d)", we
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4164 ;; should let the comma separate the function arguments instead. And
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4165 ;; in a context where the value of the expression is taken, e.g. in
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4166 ;; "if (a < b || c > d)", it's probably not a template.
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4167 (defvar c-restricted-<>-arglists nil)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4168
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4169 ;; Dynamically bound variables that instructs
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4170 ;; `c-forward-keyword-clause', `c-forward-<>-arglist',
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4171 ;; `c-forward-name', `c-forward-type', `c-forward-decl-or-cast-1', and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4172 ;; `c-forward-label' to record the ranges of all the type and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4173 ;; reference identifiers they encounter. They will build lists on
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4174 ;; these variables where each element is a cons of the buffer
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4175 ;; positions surrounding each identifier. This recording is only
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4176 ;; activated when `c-record-type-identifiers' is non-nil.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4177 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4178 ;; All known types that can't be identifiers are recorded, and also
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4179 ;; other possible types if `c-promote-possible-types' is set.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4180 ;; Recording is however disabled inside angle bracket arglists that
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4181 ;; are encountered inside names and other angle bracket arglists.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4182 ;; Such occurrences are taken care of by `c-font-lock-<>-arglists'
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4183 ;; instead.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4184 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4185 ;; Only the names in C++ template style references (e.g. "tmpl" in
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4186 ;; "tmpl<a,b>::foo") are recorded as references, other references
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4187 ;; aren't handled here.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4188 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4189 ;; `c-forward-label' records the label identifier(s) on
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4190 ;; `c-record-ref-identifiers'.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4191 (defvar c-record-type-identifiers nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4192 (defvar c-record-ref-identifiers nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4193
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4194 ;; This variable will receive a cons cell of the range of the last
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4195 ;; single identifier symbol stepped over by `c-forward-name' if it's
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4196 ;; successful. This is the range that should be put on one of the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4197 ;; record lists above by the caller. It's assigned nil if there's no
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4198 ;; such symbol in the name.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4199 (defvar c-last-identifier-range nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4200
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4201 (defmacro c-record-type-id (range)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4202 (if (eq (car-safe range) 'cons)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4203 ;; Always true.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4204 `(setq c-record-type-identifiers
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4205 (cons ,range c-record-type-identifiers))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4206 `(let ((range ,range))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4207 (if range
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4208 (setq c-record-type-identifiers
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4209 (cons range c-record-type-identifiers))))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4210
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4211 (defmacro c-record-ref-id (range)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4212 (if (eq (car-safe range) 'cons)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4213 ;; Always true.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4214 `(setq c-record-ref-identifiers
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4215 (cons ,range c-record-ref-identifiers))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4216 `(let ((range ,range))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4217 (if range
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4218 (setq c-record-ref-identifiers
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4219 (cons range c-record-ref-identifiers))))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4220
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4221 ;; Dynamically bound variable that instructs `c-forward-type' to
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4222 ;; record the ranges of types that only are found. Behaves otherwise
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4223 ;; like `c-record-type-identifiers'.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4224 (defvar c-record-found-types nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4225
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4226 (defmacro c-forward-keyword-prefixed-id (type)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4227 ;; Used internally in `c-forward-keyword-clause' to move forward
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4228 ;; over a type (if TYPE is 'type) or a name (otherwise) which
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4229 ;; possibly is prefixed by keywords and their associated clauses.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4230 ;; Try with a type/name first to not trip up on those that begin
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4231 ;; with a keyword. Return t if a known or found type is moved
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4232 ;; over. The point is clobbered if nil is returned. If range
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4233 ;; recording is enabled, the identifier is recorded on as a type
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4234 ;; if TYPE is 'type or as a reference if TYPE is 'ref.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4235 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4236 ;; This macro might do hidden buffer changes.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4237 `(let (res)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4238 (while (if (setq res ,(if (eq type 'type)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4239 `(c-forward-type)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4240 `(c-forward-name)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4241 nil
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4242 (and (looking-at c-keywords-regexp)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4243 (c-forward-keyword-clause 1))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4244 (when (memq res '(t known found prefix))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4245 ,(when (eq type 'ref)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4246 `(when c-record-type-identifiers
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4247 (c-record-ref-id c-last-identifier-range)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4248 t)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4249
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4250 (defmacro c-forward-id-comma-list (type update-safe-pos)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4251 ;; Used internally in `c-forward-keyword-clause' to move forward
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4252 ;; over a comma separated list of types or names using
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4253 ;; `c-forward-keyword-prefixed-id'.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4254 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4255 ;; This macro might do hidden buffer changes.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4256 `(while (and (progn
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4257 ,(when update-safe-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4258 `(setq safe-pos (point)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4259 (eq (char-after) ?,))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4260 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4261 (forward-char)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4262 (c-forward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4263 (c-forward-keyword-prefixed-id ,type)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4264
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4265 (defun c-forward-keyword-clause (match)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4266 ;; Submatch MATCH in the current match data is assumed to surround a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4267 ;; token. If it's a keyword, move over it and any immediately
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4268 ;; following clauses associated with it, stopping at the start of
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4269 ;; the next token. t is returned in that case, otherwise the point
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4270 ;; stays and nil is returned. The kind of clauses that are
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4271 ;; recognized are those specified by `c-type-list-kwds',
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4272 ;; `c-ref-list-kwds', `c-colon-type-list-kwds',
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4273 ;; `c-paren-nontype-kwds', `c-paren-type-kwds', `c-<>-type-kwds',
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4274 ;; and `c-<>-arglist-kwds'.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4275 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4276 ;; This function records identifier ranges on
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4277 ;; `c-record-type-identifiers' and `c-record-ref-identifiers' if
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4278 ;; `c-record-type-identifiers' is non-nil.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4279 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4280 ;; Note that for `c-colon-type-list-kwds', which doesn't necessary
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4281 ;; apply directly after the keyword, the type list is moved over
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4282 ;; only when there is no unaccounted token before it (i.e. a token
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4283 ;; that isn't moved over due to some other keyword list). The
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4284 ;; identifier ranges in the list are still recorded if that should
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4285 ;; be done, though.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4286 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4287 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4288
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4289 (let ((kwd-sym (c-keyword-sym (match-string match))) safe-pos pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4290 ;; The call to `c-forward-<>-arglist' below is made after
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4291 ;; `c-<>-sexp-kwds' keywords, so we're certain they actually
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4292 ;; are angle bracket arglists and `c-restricted-<>-arglists'
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4293 ;; should therefore be nil.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4294 (c-parse-and-markup-<>-arglists t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4295 c-restricted-<>-arglists)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4296
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4297 (when kwd-sym
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4298 (goto-char (match-end match))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4299 (c-forward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4300 (setq safe-pos (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4301
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4302 (cond
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4303 ((and (c-keyword-member kwd-sym 'c-type-list-kwds)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4304 (c-forward-keyword-prefixed-id type))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4305 ;; There's a type directly after a keyword in `c-type-list-kwds'.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4306 (c-forward-id-comma-list type t))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4307
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4308 ((and (c-keyword-member kwd-sym 'c-ref-list-kwds)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4309 (c-forward-keyword-prefixed-id ref))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4310 ;; There's a name directly after a keyword in `c-ref-list-kwds'.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4311 (c-forward-id-comma-list ref t))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4312
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4313 ((and (c-keyword-member kwd-sym 'c-paren-any-kwds)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4314 (eq (char-after) ?\())
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4315 ;; There's an open paren after a keyword in `c-paren-any-kwds'.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4316
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4317 (forward-char)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4318 (when (and (setq pos (c-up-list-forward))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4319 (eq (char-before pos) ?\)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4320 (when (and c-record-type-identifiers
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4321 (c-keyword-member kwd-sym 'c-paren-type-kwds))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4322 ;; Use `c-forward-type' on every identifier we can find
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4323 ;; inside the paren, to record the types.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4324 (while (c-syntactic-re-search-forward c-symbol-start pos t)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4325 (goto-char (match-beginning 0))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4326 (unless (c-forward-type)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4327 (looking-at c-symbol-key) ; Always matches.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4328 (goto-char (match-end 0)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4329
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4330 (goto-char pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4331 (c-forward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4332 (setq safe-pos (point))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4333
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4334 ((and (c-keyword-member kwd-sym 'c-<>-sexp-kwds)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4335 (eq (char-after) ?<)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4336 (c-forward-<>-arglist (c-keyword-member kwd-sym 'c-<>-type-kwds)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4337 (c-forward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4338 (setq safe-pos (point)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4339
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4340 ((and (c-keyword-member kwd-sym 'c-nonsymbol-sexp-kwds)
52605
50c6e94a91cb (c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents: 52401
diff changeset
4341 (not (looking-at c-symbol-start))
50c6e94a91cb (c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents: 52401
diff changeset
4342 (c-safe (c-forward-sexp) t))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4343 (c-forward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4344 (setq safe-pos (point))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4345
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4346 (when (c-keyword-member kwd-sym 'c-colon-type-list-kwds)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4347 (if (eq (char-after) ?:)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4348 ;; If we are at the colon already, we move over the type
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4349 ;; list after it.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4350 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4351 (forward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4352 (c-forward-syntactic-ws)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4353 (when (c-forward-keyword-prefixed-id type)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4354 (c-forward-id-comma-list type t)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4355 ;; Not at the colon, so stop here. But the identifier
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4356 ;; ranges in the type list later on should still be
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4357 ;; recorded.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4358 (and c-record-type-identifiers
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4359 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4360 ;; If a keyword matched both one of the types above and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4361 ;; this one, we match `c-colon-type-list-re' after the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4362 ;; clause matched above.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4363 (goto-char safe-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4364 (looking-at c-colon-type-list-re))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4365 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4366 (goto-char (match-end 0))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4367 (c-forward-syntactic-ws)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4368 (c-forward-keyword-prefixed-id type))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4369 ;; There's a type after the `c-colon-type-list-re' match
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4370 ;; after a keyword in `c-colon-type-list-kwds'.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4371 (c-forward-id-comma-list type nil))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4372
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4373 (goto-char safe-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4374 t)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4375
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4376 (defun c-forward-<>-arglist (all-types)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4377 ;; The point is assumed to be at a "<". Try to treat it as the open
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4378 ;; paren of an angle bracket arglist and move forward to the the
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4379 ;; corresponding ">". If successful, the point is left after the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4380 ;; ">" and t is returned, otherwise the point isn't moved and nil is
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4381 ;; returned. If ALL-TYPES is t then all encountered arguments in
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4382 ;; the arglist that might be types are treated as found types.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4383 ;;
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4384 ;; The variable `c-parse-and-markup-<>-arglists' controls how this
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4385 ;; function handles text properties on the angle brackets and argument
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4386 ;; separating commas.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4387 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4388 ;; `c-restricted-<>-arglists' controls how lenient the template
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4389 ;; arglist recognition should be.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4390 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4391 ;; This function records identifier ranges on
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4392 ;; `c-record-type-identifiers' and `c-record-ref-identifiers' if
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4393 ;; `c-record-type-identifiers' is non-nil.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4394 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4395 ;; This function might do hidden buffer changes.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4396
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4397 (let ((start (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4398 ;; If `c-record-type-identifiers' is set then activate
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4399 ;; recording of any found types that constitute an argument in
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4400 ;; the arglist.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4401 (c-record-found-types (if c-record-type-identifiers t)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4402 (if (catch 'angle-bracket-arglist-escape
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4403 (setq c-record-found-types
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4404 (c-forward-<>-arglist-recur all-types)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4405 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4406 (when (consp c-record-found-types)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4407 (setq c-record-type-identifiers
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4408 ;; `nconc' doesn't mind that the tail of
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4409 ;; `c-record-found-types' is t.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4410 (nconc c-record-found-types c-record-type-identifiers)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4411 t)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4412
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4413 (goto-char start)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4414 nil)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4415
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4416 (defun c-forward-<>-arglist-recur (all-types)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4417 ;; Recursive part of `c-forward-<>-arglist'.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4418 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4419 ;; This function might do hidden buffer changes.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4420
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4421 (let ((start (point)) res pos tmp
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4422 ;; Cover this so that any recorded found type ranges are
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4423 ;; automatically lost if it turns out to not be an angle
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4424 ;; bracket arglist. It's propagated through the return value
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4425 ;; on successful completion.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4426 (c-record-found-types c-record-found-types)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4427 ;; List that collects the positions after the argument
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4428 ;; separating ',' in the arglist.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4429 arg-start-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4430
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4431 ;; If the '<' has paren open syntax then we've marked it as an angle
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4432 ;; bracket arglist before, so skip to the end.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4433 (if (and (not c-parse-and-markup-<>-arglists)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4434 (c-get-char-property (point) 'syntax-table))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4435
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4436 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4437 (forward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4438 (if (and (c-go-up-list-forward)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4439 (eq (char-before) ?>))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4440 t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4441
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4442 ;; Got unmatched paren angle brackets. We don't clear the paren
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4443 ;; syntax properties and retry, on the basis that it's very
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4444 ;; unlikely that paren angle brackets become operators by code
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4445 ;; manipulation. It's far more likely that it doesn't match due
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4446 ;; to narrowing or some temporary change.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4447 (goto-char start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4448 nil))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4449
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4450 (forward-char)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4451 (unless (looking-at c-<-op-cont-regexp)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4452 (while (and
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4453 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4454
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4455 (when c-record-type-identifiers
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4456 (if all-types
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4457
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4458 ;; All encountered identifiers are types, so set the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4459 ;; promote flag and parse the type.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4460 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4461 (c-forward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4462 (when (looking-at c-identifier-start)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4463 (let ((c-promote-possible-types t))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4464 (c-forward-type))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4465
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4466 ;; Check if this arglist argument is a sole type. If
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4467 ;; it's known then it's recorded in
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4468 ;; `c-record-type-identifiers'. If it only is found
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4469 ;; then it's recorded in `c-record-found-types' which we
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4470 ;; might roll back if it turns out that this isn't an
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4471 ;; angle bracket arglist afterall.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4472 (when (memq (char-before) '(?, ?<))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4473 (let ((orig-record-found-types c-record-found-types))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4474 (c-forward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4475 (and (memq (c-forward-type) '(known found))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4476 (not (looking-at "[,>]"))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4477 ;; A found type was recorded but it's not the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4478 ;; only thing in the arglist argument, so reset
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4479 ;; `c-record-found-types'.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4480 (setq c-record-found-types
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4481 orig-record-found-types))))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4482
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4483 (setq pos (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4484 (or (when (eq (char-after) ?>)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4485 ;; Must check for '>' at the very start separately,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4486 ;; since the regexp below has to avoid ">>" without
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4487 ;; using \\=.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4488 (forward-char)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4489 t)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4490
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4491 ;; Note: These regexps exploit the match order in \| so
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4492 ;; that "<>" is matched by "<" rather than "[^>:-]>".
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4493 (c-syntactic-re-search-forward
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4494 (if c-restricted-<>-arglists
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4495 ;; Stop on ',', '|', '&', '+' and '-' to catch
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4496 ;; common binary operators that could be between
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4497 ;; two comparison expressions "a<b" and "c>d".
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4498 "[<;{},|&+-]\\|\\([^>:-]>\\)"
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4499 ;; Otherwise we still stop on ',' to find the
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4500 ;; argument start positions.
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4501 "[<;{},]\\|\\([^>:-]>\\)")
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4502 nil 'move t t 1)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4503
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4504 ;; If the arglist starter has lost its open paren
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4505 ;; syntax but not the closer, we won't find the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4506 ;; closer above since we only search in the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4507 ;; balanced sexp. In that case we stop just short
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4508 ;; of it so check if the following char is the closer.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4509 (when (eq (char-after) ?>)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4510 (forward-char)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4511 t)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4512
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4513 (cond
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4514 ((eq (char-before) ?>)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4515 ;; Either an operator starting with '>' or the end of
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4516 ;; the angle bracket arglist.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4517
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4518 (if (looking-at c->-op-cont-regexp)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4519 (progn
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4520 (goto-char (match-end 0))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4521 t) ; Continue the loop.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4522
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4523 ;; The angle bracket arglist is finished.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4524 (when c-parse-and-markup-<>-arglists
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4525 (while arg-start-pos
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4526 (c-put-c-type-property (1- (car arg-start-pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4527 'c-<>-arg-sep)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4528 (setq arg-start-pos (cdr arg-start-pos)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4529 (c-mark-<-as-paren start)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4530 (c-mark->-as-paren (1- (point))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4531 (setq res t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4532 nil)) ; Exit the loop.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4533
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4534 ((eq (char-before) ?<)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4535 ;; Either an operator starting with '<' or a nested arglist.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4536
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4537 (setq pos (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4538 (let (id-start id-end subres keyword-match)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4539 (if (if (looking-at c-<-op-cont-regexp)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4540 (setq tmp (match-end 0))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4541 (setq tmp pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4542 (backward-char)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4543 (not
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4544 (and
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4545
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4546 (save-excursion
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4547 ;; There's always an identifier before an angle
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4548 ;; bracket arglist, or a keyword in
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4549 ;; `c-<>-type-kwds' or `c-<>-arglist-kwds'.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4550 (c-backward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4551 (setq id-end (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4552 (c-simple-skip-symbol-backward)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4553 (when (or (setq keyword-match
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4554 (looking-at c-opt-<>-sexp-key))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4555 (not (looking-at c-keywords-regexp)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4556 (setq id-start (point))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4557
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4558 (setq subres
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4559 (let ((c-record-type-identifiers nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4560 (c-record-found-types nil))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4561 (c-forward-<>-arglist-recur
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4562 (and keyword-match
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4563 (c-keyword-member
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4564 (c-keyword-sym (match-string 1))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4565 'c-<>-type-kwds)))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4566 )))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4567
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4568 ;; It was not an angle bracket arglist.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4569 (goto-char tmp)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4570
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4571 ;; It was an angle bracket arglist.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4572 (setq c-record-found-types subres)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4573
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4574 ;; Record the identifier before the template as a type
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4575 ;; or reference depending on whether the arglist is last
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4576 ;; in a qualified identifier.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4577 (when (and c-record-type-identifiers
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4578 (not keyword-match))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4579 (if (and c-opt-identifier-concat-key
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4580 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4581 (c-forward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4582 (looking-at c-opt-identifier-concat-key)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4583 (c-record-ref-id (cons id-start id-end))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4584 (c-record-type-id (cons id-start id-end))))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4585 t)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4586
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4587 ((and (eq (char-before) ?,)
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
4588 (not c-restricted-<>-arglists))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4589 ;; Just another argument. Record the position. The
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4590 ;; type check stuff that made us stop at it is at
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4591 ;; the top of the loop.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4592 (setq arg-start-pos (cons (point) arg-start-pos)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4593
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4594 (t
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4595 ;; Got a character that can't be in an angle bracket
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4596 ;; arglist argument. Abort using `throw', since
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4597 ;; it's useless to try to find a surrounding arglist
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4598 ;; if we're nested.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4599 (throw 'angle-bracket-arglist-escape nil))))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4600
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4601 (if res
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4602 (or c-record-found-types t)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4603
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4604 (defun c-backward-<>-arglist (all-types &optional limit)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4605 ;; The point is assumed to be directly after a ">". Try to treat it
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4606 ;; as the close paren of an angle bracket arglist and move back to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4607 ;; the corresponding "<". If successful, the point is left at
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4608 ;; the "<" and t is returned, otherwise the point isn't moved and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4609 ;; nil is returned. ALL-TYPES is passed on to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4610 ;; `c-forward-<>-arglist'.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4611 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4612 ;; If the optional LIMIT is given, it bounds the backward search.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4613 ;; It's then assumed to be at a syntactically relevant position.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4614 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4615 ;; This is a wrapper around `c-forward-<>-arglist'. See that
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4616 ;; function for more details.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4617
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4618 (let ((start (point)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4619 (backward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4620 (if (and (not c-parse-and-markup-<>-arglists)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4621 (c-get-char-property (point) 'syntax-table))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4622
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4623 (if (and (c-go-up-list-backward)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4624 (eq (char-after) ?<))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4625 t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4626 ;; See corresponding note in `c-forward-<>-arglist'.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4627 (goto-char start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4628 nil)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4629
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4630 (while (progn
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4631 (c-syntactic-skip-backward "^<;{}" limit t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4632
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4633 (and
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4634 (if (eq (char-before) ?<)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4635 t
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4636 ;; Stopped at bob or a char that isn't allowed in an
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4637 ;; arglist, so we've failed.
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4638 (goto-char start)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4639 nil)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4640
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4641 (if (> (point)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4642 (progn (c-beginning-of-current-token)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4643 (point)))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4644 ;; If we moved then the "<" was part of some
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4645 ;; multicharacter token.
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4646 t
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4647
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4648 (backward-char)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4649 (let ((beg-pos (point)))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4650 (if (c-forward-<>-arglist all-types)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4651 (cond ((= (point) start)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4652 ;; Matched the arglist. Break the while.
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4653 (goto-char beg-pos)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4654 nil)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4655 ((> (point) start)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4656 ;; We started from a non-paren ">" inside an
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4657 ;; arglist.
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4658 (goto-char start)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4659 nil)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4660 (t
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4661 ;; Matched a shorter arglist. Can be a nested
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4662 ;; one so continue looking.
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4663 (goto-char beg-pos)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4664 t))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
4665 t))))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4666
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4667 (/= (point) start))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4668
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4669 (defun c-forward-name ()
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4670 ;; Move forward over a complete name if at the beginning of one,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4671 ;; stopping at the next following token. If the point is not at
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4672 ;; something that are recognized as name then it stays put. A name
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4673 ;; could be something as simple as "foo" in C or something as
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4674 ;; complex as "X<Y<class A<int>::B, BIT_MAX >> b>, ::operator<> ::
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4675 ;; Z<(a>b)> :: operator const X<&foo>::T Q::G<unsigned short
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4676 ;; int>::*volatile const" in C++ (this function is actually little
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4677 ;; more than a `looking-at' call in all modes except those that,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4678 ;; like C++, have `c-recognize-<>-arglists' set). Return nil if no
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4679 ;; name is found, 'template if it's an identifier ending with an
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4680 ;; angle bracket arglist, 'operator of it's an operator identifier,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4681 ;; or t if it's some other kind of name.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4682 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4683 ;; This function records identifier ranges on
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4684 ;; `c-record-type-identifiers' and `c-record-ref-identifiers' if
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4685 ;; `c-record-type-identifiers' is non-nil.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4686 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4687 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4688
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4689 (let ((pos (point)) (start (point)) res id-start id-end
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4690 ;; Turn off `c-promote-possible-types' here since we might
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4691 ;; call `c-forward-<>-arglist' and we don't want it to promote
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4692 ;; every suspect thing in the arglist to a type. We're
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4693 ;; typically called from `c-forward-type' in this case, and
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4694 ;; the caller only wants the top level type that it finds to
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4695 ;; be promoted.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4696 c-promote-possible-types)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4697 (while
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4698 (and
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4699 (looking-at c-identifier-key)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4700
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4701 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4702 ;; Check for keyword. We go to the last symbol in
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4703 ;; `c-identifier-key' first.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4704 (goto-char (setq id-end (match-end 0)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4705 (c-simple-skip-symbol-backward)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4706 (setq id-start (point))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4707
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4708 (if (looking-at c-keywords-regexp)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4709 (when (and (c-major-mode-is 'c++-mode)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4710 (looking-at
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4711 (cc-eval-when-compile
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4712 (concat "\\(operator\\|\\(template\\)\\)"
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4713 "\\(" (c-lang-const c-nonsymbol-key c++)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4714 "\\|$\\)")))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4715 (if (match-beginning 2)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4716 ;; "template" is only valid inside an
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4717 ;; identifier if preceded by "::".
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4718 (save-excursion
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4719 (c-backward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4720 (and (c-safe (backward-char 2) t)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4721 (looking-at "::")))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4722 t))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4723
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4724 ;; Handle a C++ operator or template identifier.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4725 (goto-char id-end)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4726 (c-forward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4727 (cond ((eq (char-before id-end) ?e)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4728 ;; Got "... ::template".
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4729 (let ((subres (c-forward-name)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4730 (when subres
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4731 (setq pos (point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4732 res subres))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4733
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4734 ((looking-at c-identifier-start)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4735 ;; Got a cast operator.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4736 (when (c-forward-type)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4737 (setq pos (point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4738 res 'operator)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4739 ;; Now we should match a sequence of either
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4740 ;; '*', '&' or a name followed by ":: *",
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4741 ;; where each can be followed by a sequence
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4742 ;; of `c-opt-type-modifier-key'.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4743 (while (cond ((looking-at "[*&]")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4744 (goto-char (match-end 0))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4745 t)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4746 ((looking-at c-identifier-start)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4747 (and (c-forward-name)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4748 (looking-at "::")
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4749 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4750 (goto-char (match-end 0))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4751 (c-forward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4752 (eq (char-after) ?*))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4753 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4754 (forward-char)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4755 t))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4756 (while (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4757 (c-forward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4758 (setq pos (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4759 (looking-at c-opt-type-modifier-key))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4760 (goto-char (match-end 1))))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4761
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4762 ((looking-at c-overloadable-operators-regexp)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4763 ;; Got some other operator.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4764 (setq c-last-identifier-range
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4765 (cons (point) (match-end 0)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4766 (goto-char (match-end 0))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4767 (c-forward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4768 (setq pos (point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4769 res 'operator)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4770
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4771 nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4772
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4773 ;; `id-start' is equal to `id-end' if we've jumped over
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4774 ;; an identifier that doesn't end with a symbol token.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4775 ;; That can occur e.g. for Java import directives on the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4776 ;; form "foo.bar.*".
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4777 (when (and id-start (/= id-start id-end))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4778 (setq c-last-identifier-range
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4779 (cons id-start id-end)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4780 (goto-char id-end)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4781 (c-forward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4782 (setq pos (point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4783 res t)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4784
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4785 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4786 (goto-char pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4787 (when (or c-opt-identifier-concat-key
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4788 c-recognize-<>-arglists)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4789
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4790 (cond
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4791 ((and c-opt-identifier-concat-key
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4792 (looking-at c-opt-identifier-concat-key))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4793 ;; Got a concatenated identifier. This handles the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4794 ;; cases with tricky syntactic whitespace that aren't
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4795 ;; covered in `c-identifier-key'.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4796 (goto-char (match-end 0))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4797 (c-forward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4798 t)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4799
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4800 ((and c-recognize-<>-arglists
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4801 (eq (char-after) ?<))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4802 ;; Maybe an angle bracket arglist.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4803
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4804 (when (let (c-record-type-identifiers
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4805 c-record-found-types)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4806 (c-forward-<>-arglist nil))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4807
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4808 (c-add-type start (1+ pos))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4809 (c-forward-syntactic-ws)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4810 (setq pos (point)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4811 c-last-identifier-range nil)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4812
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4813 (if (and c-opt-identifier-concat-key
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4814 (looking-at c-opt-identifier-concat-key))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4815
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4816 ;; Continue if there's an identifier concatenation
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4817 ;; operator after the template argument.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4818 (progn
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4819 (when (and c-record-type-identifiers id-start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4820 (c-record-ref-id (cons id-start id-end)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4821 (forward-char 2)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4822 (c-forward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4823 t)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4824
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4825 (when (and c-record-type-identifiers id-start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4826 (c-record-type-id (cons id-start id-end)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4827 (setq res 'template)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4828 nil)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4829 )))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4830
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4831 (goto-char pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4832 res))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4833
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4834 (defun c-forward-type ()
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4835 ;; Move forward over a type spec if at the beginning of one,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4836 ;; stopping at the next following token. Return t if it's a known
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
4837 ;; type that can't be a name or other expression, 'known if it's an
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
4838 ;; otherwise known type (according to `*-font-lock-extra-types'),
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
4839 ;; 'prefix if it's a known prefix of a type, 'found if it's a type
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
4840 ;; that matches one in `c-found-types', 'maybe if it's an identfier
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
4841 ;; that might be a type, or nil if it can't be a type (the point
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
4842 ;; isn't moved then). The point is assumed to be at the beginning
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
4843 ;; of a token.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4844 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4845 ;; Note that this function doesn't skip past the brace definition
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4846 ;; that might be considered part of the type, e.g.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4847 ;; "enum {a, b, c} foo".
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4848 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4849 ;; This function records identifier ranges on
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4850 ;; `c-record-type-identifiers' and `c-record-ref-identifiers' if
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4851 ;; `c-record-type-identifiers' is non-nil.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4852 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4853 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4854
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4855 (let ((start (point)) pos res name-res id-start id-end id-range)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4856
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4857 ;; Skip leading type modifiers. If any are found we know it's a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4858 ;; prefix of a type.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4859 (when c-opt-type-modifier-key
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4860 (while (looking-at c-opt-type-modifier-key)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4861 (goto-char (match-end 1))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4862 (c-forward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4863 (setq res 'prefix)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4864
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4865 (cond
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4866 ((looking-at c-type-prefix-key)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4867 ;; Looking at a keyword that prefixes a type identifier,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4868 ;; e.g. "class".
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4869 (goto-char (match-end 1))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4870 (c-forward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4871 (setq pos (point))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4872 (if (memq (setq name-res (c-forward-name)) '(t template))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4873 (progn
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4874 (when (eq name-res t)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4875 ;; In many languages the name can be used without the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4876 ;; prefix, so we add it to `c-found-types'.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4877 (c-add-type pos (point))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4878 (when (and c-record-type-identifiers
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4879 c-last-identifier-range)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4880 (c-record-type-id c-last-identifier-range)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4881 (setq res t))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4882 ;; Invalid syntax.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4883 (goto-char start)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4884 (setq res nil)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4885
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4886 ((progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4887 (setq pos nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4888 (if (looking-at c-identifier-start)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4889 (save-excursion
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4890 (setq id-start (point)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4891 name-res (c-forward-name))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4892 (when name-res
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4893 (setq id-end (point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4894 id-range c-last-identifier-range))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4895 (and (cond ((looking-at c-primitive-type-key)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4896 (setq res t))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4897 ((c-with-syntax-table c-identifier-syntax-table
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4898 (looking-at c-known-type-key))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4899 (setq res 'known)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4900 (or (not id-end)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4901 (>= (save-excursion
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4902 (save-match-data
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4903 (goto-char (match-end 1))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4904 (c-forward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4905 (setq pos (point))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4906 id-end)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4907 (setq res nil))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4908 ;; Looking at a primitive or known type identifier. We've
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4909 ;; checked for a name first so that we don't go here if the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4910 ;; known type match only is a prefix of another name.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4911
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4912 (setq id-end (match-end 1))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4913
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4914 (when (and c-record-type-identifiers
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4915 (or c-promote-possible-types (eq res t)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4916 (c-record-type-id (cons (match-beginning 1) (match-end 1))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4917
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4918 (if (and c-opt-type-component-key
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4919 (save-match-data
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4920 (looking-at c-opt-type-component-key)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4921 ;; There might be more keywords for the type.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4922 (let (safe-pos)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4923 (c-forward-keyword-clause 1)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4924 (while (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4925 (setq safe-pos (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4926 (looking-at c-opt-type-component-key))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4927 (when (and c-record-type-identifiers
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4928 (looking-at c-primitive-type-key))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4929 (c-record-type-id (cons (match-beginning 1)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4930 (match-end 1))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4931 (c-forward-keyword-clause 1))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4932 (if (looking-at c-primitive-type-key)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4933 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4934 (when c-record-type-identifiers
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4935 (c-record-type-id (cons (match-beginning 1)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4936 (match-end 1))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4937 (c-forward-keyword-clause 1)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4938 (setq res t))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4939 (goto-char safe-pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4940 (setq res 'prefix)))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4941 (unless (save-match-data (c-forward-keyword-clause 1))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4942 (if pos
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4943 (goto-char pos)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4944 (goto-char (match-end 1))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4945 (c-forward-syntactic-ws)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4946
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4947 (name-res
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4948 (cond ((eq name-res t)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4949 ;; A normal identifier.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4950 (goto-char id-end)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4951 (if (or res c-promote-possible-types)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4952 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4953 (c-add-type id-start id-end)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4954 (when (and c-record-type-identifiers id-range)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4955 (c-record-type-id id-range))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4956 (unless res
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4957 (setq res 'found)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4958 (setq res (if (c-check-type id-start id-end)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4959 ;; It's an identifier that has been used as
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4960 ;; a type somewhere else.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4961 'found
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4962 ;; It's an identifier that might be a type.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4963 'maybe))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4964 ((eq name-res 'template)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4965 ;; A template is a type.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4966 (goto-char id-end)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4967 (setq res t))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4968 (t
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4969 ;; Otherwise it's an operator identifier, which is not a type.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4970 (goto-char start)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4971 (setq res nil)))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4972
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4973 (when res
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4974 ;; Skip trailing type modifiers. If any are found we know it's
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4975 ;; a type.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4976 (when c-opt-type-modifier-key
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4977 (while (looking-at c-opt-type-modifier-key)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4978 (goto-char (match-end 1))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4979 (c-forward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4980 (setq res t)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4981
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4982 ;; Step over any type suffix operator. Do not let the existence
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4983 ;; of these alter the classification of the found type, since
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4984 ;; these operators typically are allowed in normal expressions
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4985 ;; too.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4986 (when c-opt-type-suffix-key
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4987 (while (looking-at c-opt-type-suffix-key)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4988 (goto-char (match-end 1))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4989 (c-forward-syntactic-ws)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4990
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4991 (when c-opt-type-concat-key
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4992 ;; Look for a trailing operator that concatenates the type
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4993 ;; with a following one, and if so step past that one through
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4994 ;; a recursive call. Note that we don't record concatenated
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4995 ;; types in `c-found-types' - it's the component types that
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
4996 ;; are recorded when appropriate.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4997 (setq pos (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4998 (let* ((c-promote-possible-types (or (memq res '(t known))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
4999 c-promote-possible-types))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5000 ;; If we can't promote then set `c-record-found-types' so that
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5001 ;; we can merge in the types from the second part afterwards if
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5002 ;; it turns out to be a known type there.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5003 (c-record-found-types (and c-record-type-identifiers
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5004 (not c-promote-possible-types)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5005 subres)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5006 (if (and (looking-at c-opt-type-concat-key)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5007
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5008 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5009 (goto-char (match-end 1))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5010 (c-forward-syntactic-ws)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5011 (setq subres (c-forward-type))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5012
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5013 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5014 ;; If either operand certainly is a type then both are, but we
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5015 ;; don't let the existence of the operator itself promote two
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5016 ;; uncertain types to a certain one.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5017 (cond ((eq res t))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5018 ((eq subres t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5019 (unless (eq name-res 'template)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5020 (c-add-type id-start id-end))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5021 (when (and c-record-type-identifiers id-range)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5022 (c-record-type-id id-range))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5023 (setq res t))
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
5024 ((eq res 'known))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5025 ((eq subres 'known)
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
5026 (setq res 'known))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5027 ((eq res 'found))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5028 ((eq subres 'found)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5029 (setq res 'found))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5030 (t
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5031 (setq res 'maybe)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5032
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5033 (when (and (eq res t)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5034 (consp c-record-found-types))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5035 ;; Merge in the ranges of any types found by the second
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5036 ;; `c-forward-type'.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5037 (setq c-record-type-identifiers
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5038 ;; `nconc' doesn't mind that the tail of
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5039 ;; `c-record-found-types' is t.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5040 (nconc c-record-found-types
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5041 c-record-type-identifiers))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5042
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5043 (goto-char pos))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5044
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5045 (when (and c-record-found-types (memq res '(known found)) id-range)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5046 (setq c-record-found-types
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5047 (cons id-range c-record-found-types))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5048
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5049 ;;(message "c-forward-type %s -> %s: %s" start (point) res)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5050
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5051 res))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5052
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5053
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5054 ;; Handling of large scale constructs like statements and declarations.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
5055
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5056 ;; Macro used inside `c-forward-decl-or-cast-1'. It ought to be a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5057 ;; defsubst or perhaps even a defun, but it contains lots of free
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5058 ;; variables that refer to things inside `c-forward-decl-or-cast-1'.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5059 (defmacro c-fdoc-shift-type-backward (&optional short)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5060 ;; `c-forward-decl-or-cast-1' can consume an arbitrary length list
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5061 ;; of types when parsing a declaration, which means that it
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5062 ;; sometimes consumes the identifier in the declaration as a type.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5063 ;; This is used to "backtrack" and make the last type be treated as
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5064 ;; an identifier instead.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5065 `(progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5066 ,(unless short
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5067 ;; These identifiers are bound only in the inner let.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5068 '(setq identifier-type at-type
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5069 identifier-start type-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5070 got-parens nil
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5071 got-identifier t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5072 got-suffix t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5073 got-suffix-after-parens id-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5074 paren-depth 0))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5075
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5076 (if (setq at-type (if (eq backup-at-type 'prefix)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5077 t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5078 backup-at-type))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5079 (setq type-start backup-type-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5080 id-start backup-id-start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5081 (setq type-start start-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5082 id-start start-pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5083
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5084 ;; When these flags already are set we've found specifiers that
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5085 ;; unconditionally signal these attributes - backtracking doesn't
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5086 ;; change that. So keep them set in that case.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5087 (or at-type-decl
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5088 (setq at-type-decl backup-at-type-decl))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5089 (or maybe-typeless
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5090 (setq maybe-typeless backup-maybe-typeless))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5091
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5092 ,(unless short
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5093 ;; This identifier is bound only in the inner let.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5094 '(setq start id-start))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5095
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5096 (defun c-forward-decl-or-cast-1 (preceding-token-end context last-cast-end)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5097 ;; Move forward over a declaration or a cast if at the start of one.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5098 ;; The point is assumed to be at the start of some token. Nil is
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5099 ;; returned if no declaration or cast is recognized, and the point
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5100 ;; is clobbered in that case.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5101 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5102 ;; If a declaration is parsed:
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5103 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5104 ;; The point is left at the first token after the first complete
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5105 ;; declarator, if there is one. The return value is a cons where
79942
99c850a55c1c Correct typos, enhance comments.
Alan Mackenzie <acm@muc.de>
parents: 79838
diff changeset
5106 ;; the car is the position of the first token in the declarator. (See
99c850a55c1c Correct typos, enhance comments.
Alan Mackenzie <acm@muc.de>
parents: 79838
diff changeset
5107 ;; below for the cdr.)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5108 ;; Some examples:
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5109 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5110 ;; void foo (int a, char *b) stuff ...
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5111 ;; car ^ ^ point
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5112 ;; float (*a)[], b;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5113 ;; car ^ ^ point
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5114 ;; unsigned int a = c_style_initializer, b;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5115 ;; car ^ ^ point
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5116 ;; unsigned int a (cplusplus_style_initializer), b;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5117 ;; car ^ ^ point (might change)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5118 ;; class Foo : public Bar {}
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5119 ;; car ^ ^ point
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5120 ;; class PikeClass (int a, string b) stuff ...
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5121 ;; car ^ ^ point
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5122 ;; enum bool;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5123 ;; car ^ ^ point
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5124 ;; enum bool flag;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5125 ;; car ^ ^ point
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5126 ;; void cplusplus_function (int x) throw (Bad);
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5127 ;; car ^ ^ point
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5128 ;; Foo::Foo (int b) : Base (b) {}
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5129 ;; car ^ ^ point
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5130 ;;
79942
99c850a55c1c Correct typos, enhance comments.
Alan Mackenzie <acm@muc.de>
parents: 79838
diff changeset
5131 ;; The cdr of the return value is non-nil iff a `c-typedef-decl-kwds'
99c850a55c1c Correct typos, enhance comments.
Alan Mackenzie <acm@muc.de>
parents: 79838
diff changeset
5132 ;; specifier (e.g. class, struct, enum, typedef) is found in the
99c850a55c1c Correct typos, enhance comments.
Alan Mackenzie <acm@muc.de>
parents: 79838
diff changeset
5133 ;; declaration, i.e. the declared identifier(s) are types.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5134 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5135 ;; If a cast is parsed:
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5136 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5137 ;; The point is left at the first token after the closing paren of
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5138 ;; the cast. The return value is `cast'. Note that the start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5139 ;; position must be at the first token inside the cast parenthesis
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5140 ;; to recognize it.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5141 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5142 ;; PRECEDING-TOKEN-END is the first position after the preceding
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5143 ;; token, i.e. on the other side of the syntactic ws from the point.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5144 ;; Use a value less than or equal to (point-min) if the point is at
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5145 ;; the first token in (the visible part of) the buffer.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5146 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5147 ;; CONTEXT is a symbol that describes the context at the point:
79942
99c850a55c1c Correct typos, enhance comments.
Alan Mackenzie <acm@muc.de>
parents: 79838
diff changeset
5148 ;; 'decl In a comma-separated declaration context (typically
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5149 ;; inside a function declaration arglist).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5150 ;; '<> In an angle bracket arglist.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5151 ;; 'arglist Some other type of arglist.
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
5152 ;; nil Some other context or unknown context. Includes
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
5153 ;; within the parens of an if, for, ... construct.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5154 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5155 ;; LAST-CAST-END is the first token after the closing paren of a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5156 ;; preceding cast, or nil if none is known. If
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5157 ;; `c-forward-decl-or-cast-1' is used in succession, it should be
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5158 ;; the position after the closest preceding call where a cast was
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5159 ;; matched. In that case it's used to discover chains of casts like
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5160 ;; "(a) (b) c".
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5161 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5162 ;; This function records identifier ranges on
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5163 ;; `c-record-type-identifiers' and `c-record-ref-identifiers' if
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5164 ;; `c-record-type-identifiers' is non-nil.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5165 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5166 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5167
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5168 (let (;; `start-pos' is used below to point to the start of the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5169 ;; first type, i.e. after any leading specifiers. It might
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5170 ;; also point at the beginning of the preceding syntactic
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5171 ;; whitespace.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5172 (start-pos (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5173 ;; Set to the result of `c-forward-type'.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5174 at-type
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5175 ;; The position of the first token in what we currently
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5176 ;; believe is the type in the declaration or cast, after any
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5177 ;; specifiers and their associated clauses.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5178 type-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5179 ;; The position of the first token in what we currently
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5180 ;; believe is the declarator for the first identifier. Set
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5181 ;; when the type is found, and moved forward over any
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5182 ;; `c-decl-hangon-kwds' and their associated clauses that
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5183 ;; occurs after the type.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5184 id-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5185 ;; These store `at-type', `type-start' and `id-start' of the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5186 ;; identifier before the one in those variables. The previous
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5187 ;; identifier might turn out to be the real type in a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5188 ;; declaration if the last one has to be the declarator in it.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5189 ;; If `backup-at-type' is nil then the other variables have
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5190 ;; undefined values.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5191 backup-at-type backup-type-start backup-id-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5192 ;; Set if we've found a specifier that makes the defined
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5193 ;; identifier(s) types.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5194 at-type-decl
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5195 ;; Set if we've found a specifier that can start a declaration
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5196 ;; where there's no type.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5197 maybe-typeless
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5198 ;; If a specifier is found that also can be a type prefix,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5199 ;; these flags are set instead of those above. If we need to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5200 ;; back up an identifier, they are copied to the real flag
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5201 ;; variables. Thus they only take effect if we fail to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5202 ;; interpret it as a type.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5203 backup-at-type-decl backup-maybe-typeless
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5204 ;; Whether we've found a declaration or a cast. We might know
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5205 ;; this before we've found the type in it. It's 'ids if we've
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5206 ;; found two consecutive identifiers (usually a sure sign, but
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5207 ;; we should allow that in labels too), and t if we've found a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5208 ;; specifier keyword (a 100% sure sign).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5209 at-decl-or-cast
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5210 ;; Set when we need to back up to parse this as a declaration
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5211 ;; but not as a cast.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5212 backup-if-not-cast
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5213 ;; For casts, the return position.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5214 cast-end
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5215 ;; Save `c-record-type-identifiers' and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5216 ;; `c-record-ref-identifiers' since ranges are recorded
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5217 ;; speculatively and should be thrown away if it turns out
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5218 ;; that it isn't a declaration or cast.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5219 (save-rec-type-ids c-record-type-identifiers)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5220 (save-rec-ref-ids c-record-ref-identifiers))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5221
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5222 ;; Check for a type. Unknown symbols are treated as possible
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5223 ;; types, but they could also be specifiers disguised through
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5224 ;; macros like __INLINE__, so we recognize both types and known
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5225 ;; specifiers after them too.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5226 (while
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5227 (let* ((start (point)) kwd-sym kwd-clause-end found-type)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5228
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5229 ;; Look for a specifier keyword clause.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5230 (when (looking-at c-prefix-spec-kwds-re)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5231 (setq kwd-sym (c-keyword-sym (match-string 1)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5232 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5233 (c-forward-keyword-clause 1)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5234 (setq kwd-clause-end (point))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5235
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5236 (when (setq found-type (c-forward-type))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5237 ;; Found a known or possible type or a prefix of a known type.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5238
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5239 (when at-type
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5240 ;; Got two identifiers with nothing but whitespace
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5241 ;; between them. That can only happen in declarations.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5242 (setq at-decl-or-cast 'ids)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5243
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5244 (when (eq at-type 'found)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5245 ;; If the previous identifier is a found type we
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5246 ;; record it as a real one; it might be some sort of
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5247 ;; alias for a prefix like "unsigned".
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5248 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5249 (goto-char type-start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5250 (let ((c-promote-possible-types t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5251 (c-forward-type)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5253 (setq backup-at-type at-type
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5254 backup-type-start type-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5255 backup-id-start id-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5256 at-type found-type
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5257 type-start start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5258 id-start (point)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5259 ;; The previous ambiguous specifier/type turned out
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5260 ;; to be a type since we've parsed another one after
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5261 ;; it, so clear these backup flags.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5262 backup-at-type-decl nil
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5263 backup-maybe-typeless nil))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5264
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5265 (if kwd-sym
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5266 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5267 ;; Handle known specifier keywords and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5268 ;; `c-decl-hangon-kwds' which can occur after known
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5269 ;; types.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5270
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5271 (if (c-keyword-member kwd-sym 'c-decl-hangon-kwds)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5272 ;; It's a hang-on keyword that can occur anywhere.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5273 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5274 (setq at-decl-or-cast t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5275 (if at-type
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5276 ;; Move the identifier start position if
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5277 ;; we've passed a type.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5278 (setq id-start kwd-clause-end)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5279 ;; Otherwise treat this as a specifier and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5280 ;; move the fallback position.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5281 (setq start-pos kwd-clause-end))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5282 (goto-char kwd-clause-end))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5283
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5284 ;; It's an ordinary specifier so we know that
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5285 ;; anything before this can't be the type.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5286 (setq backup-at-type nil
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5287 start-pos kwd-clause-end)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5288
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5289 (if found-type
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5290 ;; It's ambiguous whether this keyword is a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5291 ;; specifier or a type prefix, so set the backup
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5292 ;; flags. (It's assumed that `c-forward-type'
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5293 ;; moved further than `c-forward-keyword-clause'.)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5294 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5295 (when (c-keyword-member kwd-sym 'c-typedef-decl-kwds)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5296 (setq backup-at-type-decl t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5297 (when (c-keyword-member kwd-sym 'c-typeless-decl-kwds)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5298 (setq backup-maybe-typeless t)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5299
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5300 (when (c-keyword-member kwd-sym 'c-typedef-decl-kwds)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5301 (setq at-type-decl t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5302 (when (c-keyword-member kwd-sym 'c-typeless-decl-kwds)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5303 (setq maybe-typeless t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5304
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5305 ;; Haven't matched a type so it's an umambiguous
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5306 ;; specifier keyword and we know we're in a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5307 ;; declaration.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5308 (setq at-decl-or-cast t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5309
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5310 (goto-char kwd-clause-end))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5311
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5312 ;; If the type isn't known we continue so that we'll jump
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5313 ;; over all specifiers and type identifiers. The reason
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5314 ;; to do this for a known type prefix is to make things
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5315 ;; like "unsigned INT16" work.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5316 (and found-type (not (eq found-type t))))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5317
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5318 (cond
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5319 ((eq at-type t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5320 ;; If a known type was found, we still need to skip over any
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5321 ;; hangon keyword clauses after it. Otherwise it has already
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5322 ;; been done in the loop above.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5323 (while (looking-at c-decl-hangon-key)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5324 (c-forward-keyword-clause 1))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5325 (setq id-start (point)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5326
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5327 ((eq at-type 'prefix)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5328 ;; A prefix type is itself a primitive type when it's not
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5329 ;; followed by another type.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5330 (setq at-type t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5331
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5332 ((not at-type)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5333 ;; Got no type but set things up to continue anyway to handle
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5334 ;; the various cases when a declaration doesn't start with a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5335 ;; type.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5336 (setq id-start start-pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5337
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5338 ((and (eq at-type 'maybe)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5339 (c-major-mode-is 'c++-mode))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5340 ;; If it's C++ then check if the last "type" ends on the form
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5341 ;; "foo::foo" or "foo::~foo", i.e. if it's the name of a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5342 ;; (con|de)structor.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5343 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5344 (let (name end-2 end-1)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5345 (goto-char id-start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5346 (c-backward-syntactic-ws)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5347 (setq end-2 (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5348 (when (and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5349 (c-simple-skip-symbol-backward)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5350 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5351 (setq name
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5352 (buffer-substring-no-properties (point) end-2))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5353 ;; Cheating in the handling of syntactic ws below.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5354 (< (skip-chars-backward ":~ \t\n\r\v\f") 0))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5355 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5356 (setq end-1 (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5357 (c-simple-skip-symbol-backward))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5358 (>= (point) type-start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5359 (equal (buffer-substring-no-properties (point) end-1)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5360 name))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5361 ;; It is a (con|de)structor name. In that case the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5362 ;; declaration is typeless so zap out any preceding
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5363 ;; identifier(s) that we might have taken as types.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5364 (goto-char type-start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5365 (setq at-type nil
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5366 backup-at-type nil
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5367 id-start type-start))))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5368
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5369 ;; Check for and step over a type decl expression after the thing
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5370 ;; that is or might be a type. This can't be skipped since we
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5371 ;; need the correct end position of the declarator for
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5372 ;; `max-type-decl-end-*'.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5373 (let ((start (point)) (paren-depth 0) pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5374 ;; True if there's a non-open-paren match of
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5375 ;; `c-type-decl-prefix-key'.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5376 got-prefix
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5377 ;; True if the declarator is surrounded by a parenthesis pair.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5378 got-parens
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5379 ;; True if there is an identifier in the declarator.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5380 got-identifier
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5381 ;; True if there's a non-close-paren match of
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5382 ;; `c-type-decl-suffix-key'.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5383 got-suffix
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5384 ;; True if there's a prefix match outside the outermost
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5385 ;; paren pair that surrounds the declarator.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5386 got-prefix-before-parens
76986
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5387 ;; True if there's a suffix match outside the outermost
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5388 ;; paren pair that surrounds the declarator. The value is
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5389 ;; the position of the first suffix match.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5390 got-suffix-after-parens
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5391 ;; True if we've parsed the type decl to a token that is
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5392 ;; known to end declarations in this context.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5393 at-decl-end
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5394 ;; The earlier values of `at-type' and `type-start' if we've
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5395 ;; shifted the type backwards.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5396 identifier-type identifier-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5397 ;; If `c-parse-and-markup-<>-arglists' is set we need to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5398 ;; turn it off during the name skipping below to avoid
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5399 ;; getting `c-type' properties that might be bogus. That
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5400 ;; can happen since we don't know if
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5401 ;; `c-restricted-<>-arglists' will be correct inside the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5402 ;; arglist paren that gets entered.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5403 c-parse-and-markup-<>-arglists)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5404
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5405 (goto-char id-start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5406
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5407 ;; Skip over type decl prefix operators. (Note similar code in
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5408 ;; `c-font-lock-declarators'.)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5409 (while (and (looking-at c-type-decl-prefix-key)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5410 (if (and (c-major-mode-is 'c++-mode)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5411 (match-beginning 2))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5412 ;; If the second submatch matches in C++ then
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5413 ;; we're looking at an identifier that's a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5414 ;; prefix only if it specifies a member pointer.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5415 (when (setq got-identifier (c-forward-name))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5416 (if (looking-at "\\(::\\)")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5417 ;; We only check for a trailing "::" and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5418 ;; let the "*" that should follow be
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5419 ;; matched in the next round.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5420 (progn (setq got-identifier nil) t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5421 ;; It turned out to be the real identifier,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5422 ;; so stop.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5423 nil))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5424 t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5425
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5426 (if (eq (char-after) ?\()
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5427 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5428 (setq paren-depth (1+ paren-depth))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5429 (forward-char))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5430 (unless got-prefix-before-parens
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5431 (setq got-prefix-before-parens (= paren-depth 0)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5432 (setq got-prefix t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5433 (goto-char (match-end 1)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5434 (c-forward-syntactic-ws))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5435
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5436 (setq got-parens (> paren-depth 0))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5437
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5438 ;; Skip over an identifier.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5439 (or got-identifier
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5440 (and (looking-at c-identifier-start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5441 (setq got-identifier (c-forward-name))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5442
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5443 ;; Skip over type decl suffix operators.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5444 (while (if (looking-at c-type-decl-suffix-key)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5445
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5446 (if (eq (char-after) ?\))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5447 (when (> paren-depth 0)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5448 (setq paren-depth (1- paren-depth))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5449 (forward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5450 t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5451 (when (if (save-match-data (looking-at "\\s\("))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5452 (c-safe (c-forward-sexp 1) t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5453 (goto-char (match-end 1))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5454 t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5455 (when (and (not got-suffix-after-parens)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5456 (= paren-depth 0))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5457 (setq got-suffix-after-parens (match-beginning 0)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5458 (setq got-suffix t)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5459
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5460 ;; No suffix matched. We might have matched the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5461 ;; identifier as a type and the open paren of a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5462 ;; function arglist as a type decl prefix. In that
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5463 ;; case we should "backtrack": Reinterpret the last
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5464 ;; type as the identifier, move out of the arglist and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5465 ;; continue searching for suffix operators.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5466 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5467 ;; Do this even if there's no preceding type, to cope
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5468 ;; with old style function declarations in K&R C,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5469 ;; (con|de)structors in C++ and `c-typeless-decl-kwds'
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5470 ;; style declarations. That isn't applicable in an
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5471 ;; arglist context, though.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5472 (when (and (= paren-depth 1)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5473 (not got-prefix-before-parens)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5474 (not (eq at-type t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5475 (or backup-at-type
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5476 maybe-typeless
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5477 backup-maybe-typeless
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5478 (when c-recognize-typeless-decls
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5479 (not context)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5480 (setq pos (c-up-list-forward (point)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5481 (eq (char-before pos) ?\)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5482 (c-fdoc-shift-type-backward)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5483 (goto-char pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5484 t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5485
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5486 (c-forward-syntactic-ws))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5487
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5488 (when (and (or maybe-typeless backup-maybe-typeless)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5489 (not got-identifier)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5490 (not got-prefix)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5491 at-type)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5492 ;; Have found no identifier but `c-typeless-decl-kwds' has
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5493 ;; matched so we know we're inside a declaration. The
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5494 ;; preceding type must be the identifier instead.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5495 (c-fdoc-shift-type-backward))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5496
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5497 (setq
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5498 at-decl-or-cast
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5499 (catch 'at-decl-or-cast
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5500
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
5501 ;; CASE 1
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5502 (when (> paren-depth 0)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5503 ;; Encountered something inside parens that isn't matched by
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5504 ;; the `c-type-decl-*' regexps, so it's not a type decl
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5505 ;; expression. Try to skip out to the same paren depth to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5506 ;; not confuse the cast check below.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5507 (c-safe (goto-char (scan-lists (point) 1 paren-depth)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5508 ;; If we've found a specifier keyword then it's a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5509 ;; declaration regardless.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5510 (throw 'at-decl-or-cast (eq at-decl-or-cast t)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5511
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5512 (setq at-decl-end
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5513 (looking-at (cond ((eq context '<>) "[,>]")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5514 (context "[,\)]")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5515 (t "[,;]"))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5516
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5517 ;; Now we've collected info about various characteristics of
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5518 ;; the construct we're looking at. Below follows a decision
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5519 ;; tree based on that. It's ordered to check more certain
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5520 ;; signs before less certain ones.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5521
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5522 (if got-identifier
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5523 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5524
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
5525 ;; CASE 2
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5526 (when (and (or at-type maybe-typeless)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5527 (not (or got-prefix got-parens)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5528 ;; Got another identifier directly after the type, so it's a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5529 ;; declaration.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5530 (throw 'at-decl-or-cast t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5531
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5532 (when (and got-parens
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5533 (not got-prefix)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5534 (not got-suffix-after-parens)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5535 (or backup-at-type
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5536 maybe-typeless
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5537 backup-maybe-typeless))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5538 ;; Got a declaration of the form "foo bar (gnu);" where we've
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5539 ;; recognized "bar" as the type and "gnu" as the declarator.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5540 ;; In this case it's however more likely that "bar" is the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5541 ;; declarator and "gnu" a function argument or initializer (if
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5542 ;; `c-recognize-paren-inits' is set), since the parens around
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5543 ;; "gnu" would be superfluous if it's a declarator. Shift the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5544 ;; type one step backward.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5545 (c-fdoc-shift-type-backward)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5546
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5547 ;; Found no identifier.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5548
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5549 (if backup-at-type
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5550 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5551
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
5552 ;; CASE 3
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5553 (when (= (point) start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5554 ;; Got a plain list of identifiers. If a colon follows it's
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5555 ;; a valid label. Otherwise the last one probably is the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5556 ;; declared identifier and we should back up to the previous
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5557 ;; type, providing it isn't a cast.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5558 (if (eq (char-after) ?:)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5559 ;; If we've found a specifier keyword then it's a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5560 ;; declaration regardless.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5561 (throw 'at-decl-or-cast (eq at-decl-or-cast t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5562 (setq backup-if-not-cast t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5563 (throw 'at-decl-or-cast t)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5564
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
5565 ;; CASE 4
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5566 (when (and got-suffix
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5567 (not got-prefix)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5568 (not got-parens))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5569 ;; Got a plain list of identifiers followed by some suffix.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5570 ;; If this isn't a cast then the last identifier probably is
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5571 ;; the declared one and we should back up to the previous
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5572 ;; type.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5573 (setq backup-if-not-cast t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5574 (throw 'at-decl-or-cast t)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5575
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
5576 ;; CASE 5
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5577 (when (eq at-type t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5578 ;; If the type is known we know that there can't be any
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5579 ;; identifier somewhere else, and it's only in declarations in
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5580 ;; e.g. function prototypes and in casts that the identifier may
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5581 ;; be left out.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5582 (throw 'at-decl-or-cast t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5583
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5584 (when (= (point) start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5585 ;; Only got a single identifier (parsed as a type so far).
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
5586 ;; CASE 6
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5587 (if (and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5588 ;; Check that the identifier isn't at the start of an
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5589 ;; expression.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5590 at-decl-end
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5591 (cond
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5592 ((eq context 'decl)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5593 ;; Inside an arglist that contains declarations. If K&R
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5594 ;; style declarations and parenthesis style initializers
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5595 ;; aren't allowed then the single identifier must be a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5596 ;; type, else we require that it's known or found
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5597 ;; (primitive types are handled above).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5598 (or (and (not c-recognize-knr-p)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5599 (not c-recognize-paren-inits))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5600 (memq at-type '(known found))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5601 ((eq context '<>)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5602 ;; Inside a template arglist. Accept known and found
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5603 ;; types; other identifiers could just as well be
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5604 ;; constants in C++.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5605 (memq at-type '(known found)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5606 (throw 'at-decl-or-cast t)
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
5607 ;; CASE 7
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5608 ;; Can't be a valid declaration or cast, but if we've found a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5609 ;; specifier it can't be anything else either, so treat it as
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5610 ;; an invalid/unfinished declaration or cast.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5611 (throw 'at-decl-or-cast at-decl-or-cast))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5612
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5613 (if (and got-parens
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5614 (not got-prefix)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5615 (not context)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5616 (not (eq at-type t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5617 (or backup-at-type
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5618 maybe-typeless
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5619 backup-maybe-typeless
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5620 (when c-recognize-typeless-decls
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5621 (or (not got-suffix)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5622 (not (looking-at
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5623 c-after-suffixed-type-maybe-decl-key))))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5624 ;; Got an empty paren pair and a preceding type that probably
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5625 ;; really is the identifier. Shift the type backwards to make
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5626 ;; the last one the identifier. This is analogous to the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5627 ;; "backtracking" done inside the `c-type-decl-suffix-key' loop
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5628 ;; above.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5629 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5630 ;; Exception: In addition to the conditions in that
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5631 ;; "backtracking" code, do not shift backward if we're not
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5632 ;; looking at either `c-after-suffixed-type-decl-key' or "[;,]".
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5633 ;; Since there's no preceding type, the shift would mean that
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5634 ;; the declaration is typeless. But if the regexp doesn't match
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5635 ;; then we will simply fall through in the tests below and not
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5636 ;; recognize it at all, so it's better to try it as an abstract
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5637 ;; declarator instead.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5638 (c-fdoc-shift-type-backward)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5639
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5640 ;; Still no identifier.
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
5641 ;; CASE 8
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5642 (when (and got-prefix (or got-parens got-suffix))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5643 ;; Require `got-prefix' together with either `got-parens' or
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5644 ;; `got-suffix' to recognize it as an abstract declarator:
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5645 ;; `got-parens' only is probably an empty function call.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5646 ;; `got-suffix' only can build an ordinary expression together
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5647 ;; with the preceding identifier which we've taken as a type.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5648 ;; We could actually accept on `got-prefix' only, but that can
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5649 ;; easily occur temporarily while writing an expression so we
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5650 ;; avoid that case anyway. We could do a better job if we knew
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5651 ;; the point when the fontification was invoked.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5652 (throw 'at-decl-or-cast t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5653
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
5654 ;; CASE 9
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5655 (when (and at-type
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5656 (not got-prefix)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5657 (not got-parens)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5658 got-suffix-after-parens
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5659 (eq (char-after got-suffix-after-parens) ?\())
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5660 ;; Got a type, no declarator but a paren suffix. I.e. it's a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5661 ;; normal function call afterall (or perhaps a C++ style object
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5662 ;; instantiation expression).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5663 (throw 'at-decl-or-cast nil))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5664
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
5665 ;; CASE 10
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5666 (when at-decl-or-cast
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5667 ;; By now we've located the type in the declaration that we know
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5668 ;; we're in.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5669 (throw 'at-decl-or-cast t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5670
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
5671 ;; CASE 11
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5672 (when (and got-identifier
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5673 (not context)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5674 (looking-at c-after-suffixed-type-decl-key)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5675 (if (and got-parens
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5676 (not got-prefix)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5677 (not got-suffix)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5678 (not (eq at-type t)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5679 ;; Shift the type backward in the case that there's a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5680 ;; single identifier inside parens. That can only
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5681 ;; occur in K&R style function declarations so it's
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5682 ;; more likely that it really is a function call.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5683 ;; Therefore we only do this after
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5684 ;; `c-after-suffixed-type-decl-key' has matched.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5685 (progn (c-fdoc-shift-type-backward) t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5686 got-suffix-after-parens))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5687 ;; A declaration according to `c-after-suffixed-type-decl-key'.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5688 (throw 'at-decl-or-cast t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5689
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
5690 ;; CASE 12
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5691 (when (and (or got-prefix (not got-parens))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5692 (memq at-type '(t known)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5693 ;; It's a declaration if a known type precedes it and it can't be a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5694 ;; function call.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5695 (throw 'at-decl-or-cast t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5696
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5697 ;; If we get here we can't tell if this is a type decl or a normal
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5698 ;; expression by looking at it alone. (That's under the assumption
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5699 ;; that normal expressions always can look like type decl expressions,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5700 ;; which isn't really true but the cases where it doesn't hold are so
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5701 ;; uncommon (e.g. some placements of "const" in C++) it's not worth
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5702 ;; the effort to look for them.)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5703
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5704 (unless (or at-decl-end (looking-at "=[^=]"))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5705 ;; If this is a declaration it should end here or its initializer(*)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5706 ;; should start here, so check for allowed separation tokens. Note
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5707 ;; that this rule doesn't work e.g. with a K&R arglist after a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5708 ;; function header.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5709 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5710 ;; *) Don't check for C++ style initializers using parens
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5711 ;; since those already have been matched as suffixes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5712 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5713 ;; If `at-decl-or-cast' is then we've found some other sign that
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5714 ;; it's a declaration or cast, so then it's probably an
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5715 ;; invalid/unfinished one.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5716 (throw 'at-decl-or-cast at-decl-or-cast))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5717
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5718 ;; Below are tests that only should be applied when we're certain to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5719 ;; not have parsed halfway through an expression.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5720
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
5721 ;; CASE 14
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5722 (when (memq at-type '(t known))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5723 ;; The expression starts with a known type so treat it as a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5724 ;; declaration.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5725 (throw 'at-decl-or-cast t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5726
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
5727 ;; CASE 15
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5728 (when (and (c-major-mode-is 'c++-mode)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5729 ;; In C++ we check if the identifier is a known type, since
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5730 ;; (con|de)structors use the class name as identifier.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5731 ;; We've always shifted over the identifier as a type and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5732 ;; then backed up again in this case.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5733 identifier-type
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5734 (or (memq identifier-type '(found known))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5735 (and (eq (char-after identifier-start) ?~)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5736 ;; `at-type' probably won't be 'found for
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5737 ;; destructors since the "~" is then part of the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5738 ;; type name being checked against the list of
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5739 ;; known types, so do a check without that
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5740 ;; operator.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5741 (or (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5742 (goto-char (1+ identifier-start))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5743 (c-forward-syntactic-ws)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5744 (c-with-syntax-table
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5745 c-identifier-syntax-table
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5746 (looking-at c-known-type-key)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5747 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5748 (goto-char (1+ identifier-start))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5749 ;; We have already parsed the type earlier,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5750 ;; so it'd be possible to cache the end
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5751 ;; position instead of redoing it here, but
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5752 ;; then we'd need to keep track of another
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5753 ;; position everywhere.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5754 (c-check-type (point)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5755 (progn (c-forward-type)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5756 (point))))))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5757 (throw 'at-decl-or-cast t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5758
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5759 (if got-identifier
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5760 (progn
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
5761 ;; CASE 16
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5762 (when (and got-prefix-before-parens
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5763 at-type
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5764 (or at-decl-end (looking-at "=[^=]"))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5765 (not context)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5766 (not got-suffix))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5767 ;; Got something like "foo * bar;". Since we're not inside an
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5768 ;; arglist it would be a meaningless expression because the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5769 ;; result isn't used. We therefore choose to recognize it as
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5770 ;; a declaration. Do not allow a suffix since it could then
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5771 ;; be a function call.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5772 (throw 'at-decl-or-cast t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5773
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
5774 ;; CASE 17
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5775 (when (and (or got-suffix-after-parens
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5776 (looking-at "=[^=]"))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5777 (eq at-type 'found)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5778 (not (eq context 'arglist)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5779 ;; Got something like "a (*b) (c);" or "a (b) = c;". It could
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5780 ;; be an odd expression or it could be a declaration. Treat
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5781 ;; it as a declaration if "a" has been used as a type
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5782 ;; somewhere else (if it's a known type we won't get here).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5783 (throw 'at-decl-or-cast t)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5784
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
5785 ;; CASE 18
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5786 (when (and context
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5787 (or got-prefix
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5788 (and (eq context 'decl)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5789 (not c-recognize-paren-inits)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5790 (or got-parens got-suffix))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5791 ;; Got a type followed by an abstract declarator. If `got-prefix'
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5792 ;; is set it's something like "a *" without anything after it. If
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5793 ;; `got-parens' or `got-suffix' is set it's "a()", "a[]", "a()[]",
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5794 ;; or similar, which we accept only if the context rules out
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5795 ;; expressions.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5796 (throw 'at-decl-or-cast t)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5797
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5798 ;; If we had a complete symbol table here (which rules out
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5799 ;; `c-found-types') we should return t due to the disambiguation rule
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5800 ;; (in at least C++) that anything that can be parsed as a declaration
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5801 ;; is a declaration. Now we're being more defensive and prefer to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5802 ;; highlight things like "foo (bar);" as a declaration only if we're
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5803 ;; inside an arglist that contains declarations.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5804 (eq context 'decl))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5805
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5806 ;; The point is now after the type decl expression.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5807
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5808 (cond
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5809 ;; Check for a cast.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5810 ((save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5811 (and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5812 c-cast-parens
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5813
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5814 ;; Should be the first type/identifier in a cast paren.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5815 (> preceding-token-end (point-min))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5816 (memq (char-before preceding-token-end) c-cast-parens)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5817
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5818 ;; The closing paren should follow.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5819 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5820 (c-forward-syntactic-ws)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5821 (looking-at "\\s\)"))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5822
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5823 ;; There should be a primary expression after it.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5824 (let (pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5825 (forward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5826 (c-forward-syntactic-ws)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5827 (setq cast-end (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5828 (and (looking-at c-primary-expr-regexp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5829 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5830 (setq pos (match-end 0))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5831 (or
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5832 ;; Check if the expression begins with a prefix keyword.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5833 (match-beginning 2)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5834 (if (match-beginning 1)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5835 ;; Expression begins with an ambiguous operator. Treat
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5836 ;; it as a cast if it's a type decl or if we've
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5837 ;; recognized the type somewhere else.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5838 (or at-decl-or-cast
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5839 (memq at-type '(t known found)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5840 ;; Unless it's a keyword, it's the beginning of a primary
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5841 ;; expression.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5842 (not (looking-at c-keywords-regexp)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5843 ;; If `c-primary-expr-regexp' matched a nonsymbol token, check
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5844 ;; that it matched a whole one so that we don't e.g. confuse
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5845 ;; the operator '-' with '->'. It's ok if it matches further,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5846 ;; though, since it e.g. can match the float '.5' while the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5847 ;; operator regexp only matches '.'.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5848 (or (not (looking-at c-nonsymbol-token-regexp))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5849 (<= (match-end 0) pos))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5850
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5851 ;; There should either be a cast before it or something that isn't an
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5852 ;; identifier or close paren.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5853 (> preceding-token-end (point-min))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5854 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5855 (goto-char (1- preceding-token-end))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5856 (or (eq (point) last-cast-end)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5857 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5858 (c-backward-syntactic-ws)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5859 (if (< (skip-syntax-backward "w_") 0)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5860 ;; It's a symbol. Accept it only if it's one of the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5861 ;; keywords that can precede an expression (without
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5862 ;; surrounding parens).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5863 (looking-at c-simple-stmt-key)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5864 (and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5865 ;; Check that it isn't a close paren (block close is ok,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5866 ;; though).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5867 (not (memq (char-before) '(?\) ?\])))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5868 ;; Check that it isn't a nonsymbol identifier.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5869 (not (c-on-identifier)))))))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5870
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5871 ;; Handle the cast.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5872 (when (and c-record-type-identifiers at-type (not (eq at-type t)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5873 (let ((c-promote-possible-types t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5874 (goto-char type-start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5875 (c-forward-type)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5876
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5877 (goto-char cast-end)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5878 'cast)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5879
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5880 (at-decl-or-cast
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5881 ;; We're at a declaration. Highlight the type and the following
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5882 ;; declarators.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5883
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5884 (when backup-if-not-cast
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5885 (c-fdoc-shift-type-backward t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5886
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5887 (when (and (eq context 'decl) (looking-at ","))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5888 ;; Make sure to propagate the `c-decl-arg-start' property to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5889 ;; the next argument if it's set in this one, to cope with
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5890 ;; interactive refontification.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5891 (c-put-c-type-property (point) 'c-decl-arg-start))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5892
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5893 (when (and c-record-type-identifiers at-type (not (eq at-type t)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5894 (let ((c-promote-possible-types t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5895 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5896 (goto-char type-start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5897 (c-forward-type))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5898
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5899 (cons id-start at-type-decl))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5900
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5901 (t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5902 ;; False alarm. Restore the recorded ranges.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5903 (setq c-record-type-identifiers save-rec-type-ids
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5904 c-record-ref-identifiers save-rec-ref-ids)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5905 nil))))
79943
c87032622eda Correct typos, enhance comments.
Alan Mackenzie <acm@muc.de>
parents: 79942
diff changeset
5906
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5907 (defun c-forward-label (&optional assume-markup preceding-token-end limit)
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
5908 ;; Assuming that point is at the beginning of a token, check if it starts a
76986
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5909 ;; label and if so move over it and return non-nil (t in default situations,
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5910 ;; specific symbols (see below) for interesting situations), otherwise don't
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5911 ;; move and return nil. "Label" here means "most things with a colon".
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
5912 ;;
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
5913 ;; More precisely, a "label" is regarded as one of:
76986
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5914 ;; (i) a goto target like "foo:" - returns the symbol `goto-target';
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5915 ;; (ii) A case label - either the entire construct "case FOO:", or just the
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5916 ;; bare "case", should the colon be missing. We return t;
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5917 ;; (iii) a keyword which needs a colon, like "default:" or "private:"; We
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5918 ;; return t;
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
5919 ;; (iv) One of QT's "extended" C++ variants of
76986
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5920 ;; "private:"/"protected:"/"public:"/"more:" looking like "public slots:".
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5921 ;; Returns the symbol `qt-2kwds-colon'.
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5922 ;; (v) QT's construct "signals:". Returns the symbol `qt-1kwd-colon'.
78656
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
5923 ;; (vi) One of the keywords matched by `c-opt-extra-label-key' (without any
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
5924 ;; colon). Currently (2006-03), this applies only to Objective C's
76986
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5925 ;; keywords "@private", "@protected", and "@public". Returns t.
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
5926 ;;
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
5927 ;; One of the things which will NOT be recognised as a label is a bit-field
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
5928 ;; element of a struct, something like "int foo:5".
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
5929 ;;
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
5930 ;; The end of the label is taken to be just after the colon, or the end of
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
5931 ;; the first submatch in `c-opt-extra-label-key'. The point is directly
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
5932 ;; after the end on return. The terminating char gets marked with
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
5933 ;; `c-decl-end' to improve recognition of the following declaration or
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
5934 ;; statement.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5935 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5936 ;; If ASSUME-MARKUP is non-nil, it's assumed that the preceding
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
5937 ;; label, if any, has already been marked up like that.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5938 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5939 ;; If PRECEDING-TOKEN-END is given, it should be the first position
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5940 ;; after the preceding token, i.e. on the other side of the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5941 ;; syntactic ws from the point. Use a value less than or equal to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5942 ;; (point-min) if the point is at the first token in (the visible
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5943 ;; part of) the buffer.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5944 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5945 ;; The optional LIMIT limits the forward scan for the colon.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5946 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5947 ;; This function records the ranges of the label symbols on
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5948 ;; `c-record-ref-identifiers' if `c-record-type-identifiers' (!) is
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5949 ;; non-nil.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5950 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5951 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5952
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
5953 (let ((start (point))
76986
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5954 label-end
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
5955 qt-symbol-idx
76986
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5956 macro-start ; if we're in one.
99350
c6c533f20c51 (c-forward-label): Fix for QT macros.
Alan Mackenzie <acm@muc.de>
parents: 98693
diff changeset
5957 label-type
c6c533f20c51 (c-forward-label): Fix for QT macros.
Alan Mackenzie <acm@muc.de>
parents: 98693
diff changeset
5958 kwd)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5959 (cond
79408
a29ca195b71e (c-crosses-statement-barrier-p): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 78656
diff changeset
5960 ;; "case" or "default" (Doesn't apply to AWK).
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5961 ((looking-at c-label-kwds-regexp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5962 (let ((kwd-end (match-end 1)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5963 ;; Record only the keyword itself for fontification, since in
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5964 ;; case labels the following is a constant expression and not
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5965 ;; a label.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5966 (when c-record-type-identifiers
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5967 (c-record-ref-id (cons (match-beginning 1) kwd-end)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5968
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5969 ;; Find the label end.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5970 (goto-char kwd-end)
76986
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5971 (setq label-type
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5972 (if (and (c-syntactic-re-search-forward
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5973 ;; Stop on chars that aren't allowed in expressions,
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5974 ;; and on operator chars that would be meaningless
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5975 ;; there. FIXME: This doesn't cope with ?: operators.
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5976 "[;{=,@]\\|\\(\\=\\|[^:]\\):\\([^:]\\|\\'\\)"
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5977 limit t t nil 1)
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5978 (match-beginning 2))
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5979
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5980 (progn ; there's a proper :
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5981 (goto-char (match-beginning 2)) ; just after the :
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5982 (c-put-c-type-property (1- (point)) 'c-decl-end)
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5983 t)
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5984
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5985 ;; It's an unfinished label. We consider the keyword enough
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5986 ;; to recognize it as a label, so that it gets fontified.
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5987 ;; Leave the point at the end of it, but don't put any
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5988 ;; `c-decl-end' marker.
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5989 (goto-char kwd-end)
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
5990 t))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5991
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
5992 ;; @private, @protected, @public, in Objective C, or similar.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5993 ((and c-opt-extra-label-key
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5994 (looking-at c-opt-extra-label-key))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5995 ;; For a `c-opt-extra-label-key' match, we record the whole
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5996 ;; thing for fontification. That's to get the leading '@' in
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5997 ;; Objective-C protection labels fontified.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5998 (goto-char (match-end 1))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
5999 (when c-record-type-identifiers
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6000 (c-record-ref-id (cons (match-beginning 1) (point))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6001 (c-put-c-type-property (1- (point)) 'c-decl-end)
76986
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6002 (setq label-type t))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6003
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6004 ;; All other cases of labels.
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6005 ((and c-recognize-colon-labels ; nil for AWK and IDL, otherwise t.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6006
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6007 ;; A colon label must have something before the colon.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6008 (not (eq (char-after) ?:))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6009
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6010 ;; Check that we're not after a token that can't precede a label.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6011 (or
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6012 ;; Trivially succeeds when there's no preceding token.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6013 (if preceding-token-end
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6014 (<= preceding-token-end (point-min))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6015 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6016 (c-backward-syntactic-ws)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6017 (setq preceding-token-end (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6018 (bobp)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6019
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6020 ;; Check if we're after a label, if we're after a closing
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6021 ;; paren that belong to statement, and with
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6022 ;; `c-label-prefix-re'. It's done in different order
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6023 ;; depending on `assume-markup' since the checks have
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6024 ;; different expensiveness.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6025 (if assume-markup
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6026 (or
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6027 (eq (c-get-char-property (1- preceding-token-end) 'c-type)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6028 'c-decl-end)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6029
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6030 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6031 (goto-char (1- preceding-token-end))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6032 (c-beginning-of-current-token)
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6033 (or (looking-at c-label-prefix-re)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6034 (looking-at c-block-stmt-1-key)))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6035
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6036 (and (eq (char-before preceding-token-end) ?\))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6037 (c-after-conditional)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6038
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6039 (or
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6040 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6041 (goto-char (1- preceding-token-end))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6042 (c-beginning-of-current-token)
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6043 (or (looking-at c-label-prefix-re)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6044 (looking-at c-block-stmt-1-key)))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6045
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6046 (cond
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6047 ((eq (char-before preceding-token-end) ?\))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6048 (c-after-conditional))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6049
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6050 ((eq (char-before preceding-token-end) ?:)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6051 ;; Might be after another label, so check it recursively.
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6052 (save-restriction
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6053 (save-excursion
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6054 (goto-char (1- preceding-token-end))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6055 ;; Essentially the same as the
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6056 ;; `c-syntactic-re-search-forward' regexp below.
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6057 (setq macro-start
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6058 (save-excursion (and (c-beginning-of-macro)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6059 (point))))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6060 (if macro-start (narrow-to-region macro-start (point-max)))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6061 (c-syntactic-skip-backward "^-]:?;}=*/%&|,<>!@+" nil t)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6062 ;; Note: the following should work instead of the
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6063 ;; narrow-to-region above. Investigate why not,
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6064 ;; sometime. ACM, 2006-03-31.
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6065 ;; (c-syntactic-skip-backward "^-]:?;}=*/%&|,<>!@+"
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6066 ;; macro-start t)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6067 (let ((pte (point))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6068 ;; If the caller turned on recording for us,
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6069 ;; it shouldn't apply when we check the
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6070 ;; preceding label.
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6071 c-record-type-identifiers)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6072 ;; A label can't start at a cpp directive. Check for
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6073 ;; this, since c-forward-syntactic-ws would foul up on it.
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6074 (unless (and c-opt-cpp-prefix (looking-at c-opt-cpp-prefix))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6075 (c-forward-syntactic-ws)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6076 (c-forward-label nil pte start))))))))))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6077
76986
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6078 ;; Point is still at the beginning of the possible label construct.
79408
a29ca195b71e (c-crosses-statement-barrier-p): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 78656
diff changeset
6079 ;;
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6080 ;; Check that the next nonsymbol token is ":", or that we're in one
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6081 ;; of QT's "slots" declarations. Allow '(' for the sake of macro
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6082 ;; arguments. FIXME: Should build this regexp from the language
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6083 ;; constants.
76986
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6084 (cond
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6085 ;; public: protected: private:
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6086 ((and
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6087 (c-major-mode-is 'c++-mode)
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6088 (search-forward-regexp
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6089 "\\=p\\(r\\(ivate\\|otected\\)\\|ublic\\)\\>[^_]" nil t)
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6090 (progn (backward-char)
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6091 (c-forward-syntactic-ws limit)
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6092 (looking-at ":\\([^:]\\|\\'\\)"))) ; A single colon.
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6093 (forward-char)
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6094 (setq label-type t))
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6095 ;; QT double keyword like "protected slots:" or goto target.
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6096 ((progn (goto-char start) nil))
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6097 ((when (c-syntactic-re-search-forward
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6098 "[ \t\n[:?;{=*/%&|,<>!@+-]" limit t t) ; not at EOB
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6099 (backward-char)
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6100 (setq label-end (point))
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6101 (setq qt-symbol-idx
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6102 (and (c-major-mode-is 'c++-mode)
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6103 (string-match
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6104 "\\(p\\(r\\(ivate\\|otected\\)\\|ublic\\)\\|more\\)\\>"
79408
a29ca195b71e (c-crosses-statement-barrier-p): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 78656
diff changeset
6105 (buffer-substring start (point)))))
76986
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6106 (c-forward-syntactic-ws limit)
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6107 (cond
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6108 ((looking-at ":\\([^:]\\|\\'\\)") ; A single colon.
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6109 (forward-char)
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6110 (setq label-type
99350
c6c533f20c51 (c-forward-label): Fix for QT macros.
Alan Mackenzie <acm@muc.de>
parents: 98693
diff changeset
6111 (if (or (string= "signals" ; Special QT macro
c6c533f20c51 (c-forward-label): Fix for QT macros.
Alan Mackenzie <acm@muc.de>
parents: 98693
diff changeset
6112 (setq kwd (buffer-substring-no-properties start label-end)))
c6c533f20c51 (c-forward-label): Fix for QT macros.
Alan Mackenzie <acm@muc.de>
parents: 98693
diff changeset
6113 (string= "Q_SIGNALS" kwd))
76986
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6114 'qt-1kwd-colon
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6115 'goto-target)))
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6116 ((and qt-symbol-idx
99350
c6c533f20c51 (c-forward-label): Fix for QT macros.
Alan Mackenzie <acm@muc.de>
parents: 98693
diff changeset
6117 (search-forward-regexp "\\=\\(slots\\|Q_SLOTS\\)\\>" limit t)
76986
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6118 (progn (c-forward-syntactic-ws limit)
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6119 (looking-at ":\\([^:]\\|\\'\\)"))) ; A single colon
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6120 (forward-char)
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6121 (setq label-type 'qt-2kwds-colon)))))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6122
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6123 (save-restriction
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6124 (narrow-to-region start (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6125
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6126 ;; Check that `c-nonlabel-token-key' doesn't match anywhere.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6127 (catch 'check-label
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6128 (goto-char start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6129 (while (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6130 (when (looking-at c-nonlabel-token-key)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6131 (goto-char start)
76986
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6132 (setq label-type nil)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6133 (throw 'check-label nil))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6134 (and (c-safe (c-forward-sexp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6135 (c-forward-syntactic-ws)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6136 t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6137 (not (eobp)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6138
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6139 ;; Record the identifiers in the label for fontification, unless
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6140 ;; it begins with `c-label-kwds' in which case the following
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6141 ;; identifiers are part of a (constant) expression that
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6142 ;; shouldn't be fontified.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6143 (when (and c-record-type-identifiers
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6144 (progn (goto-char start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6145 (not (looking-at c-label-kwds-regexp))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6146 (while (c-syntactic-re-search-forward c-symbol-key nil t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6147 (c-record-ref-id (cons (match-beginning 0)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6148 (match-end 0)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6149
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6150 (c-put-c-type-property (1- (point-max)) 'c-decl-end)
78656
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
6151 (goto-char (point-max)))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6152
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6153 (t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6154 ;; Not a label.
76986
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6155 (goto-char start)))
469570420bff Fix fontification of labels, and other things with ":".
Alan Mackenzie <acm@muc.de>
parents: 76723
diff changeset
6156 label-type))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6157
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6158 (defun c-forward-objc-directive ()
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6159 ;; Assuming the point is at the beginning of a token, try to move
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6160 ;; forward to the end of the Objective-C directive that starts
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6161 ;; there. Return t if a directive was fully recognized, otherwise
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6162 ;; the point is moved as far as one could be successfully parsed and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6163 ;; nil is returned.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6164 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6165 ;; This function records identifier ranges on
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6166 ;; `c-record-type-identifiers' and `c-record-ref-identifiers' if
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6167 ;; `c-record-type-identifiers' is non-nil.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6168 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6169 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6170
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6171 (let ((start (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6172 start-char
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6173 (c-promote-possible-types t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6174 ;; Turn off recognition of angle bracket arglists while parsing
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6175 ;; types here since the protocol reference list might then be
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6176 ;; considered part of the preceding name or superclass-name.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6177 c-recognize-<>-arglists)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6178
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6179 (if (or
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6180 (when (looking-at
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6181 (eval-when-compile
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6182 (c-make-keywords-re t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6183 (append (c-lang-const c-protection-kwds objc)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6184 '("@end"))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6185 'objc-mode)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6186 (goto-char (match-end 1))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6187 t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6188
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6189 (and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6190 (looking-at
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6191 (eval-when-compile
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6192 (c-make-keywords-re t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6193 '("@interface" "@implementation" "@protocol")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6194 'objc-mode)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6195
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6196 ;; Handle the name of the class itself.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6197 (progn
69140
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
6198 ; (c-forward-token-2) ; 2006/1/13 This doesn't move if the token's
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
6199 ; at EOB.
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
6200 (goto-char (match-end 0))
3d8b060d10fb cc-align.el, cc-awk.el, cc-bytecomp.el, cc-cmds.el, cc-compat.el,
Alan Mackenzie <acm@muc.de>
parents: 68773
diff changeset
6201 (c-skip-ws-forward)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6202 (c-forward-type))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6203
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6204 (catch 'break
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6205 ;; Look for ": superclass-name" or "( category-name )".
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6206 (when (looking-at "[:\(]")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6207 (setq start-char (char-after))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6208 (forward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6209 (c-forward-syntactic-ws)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6210 (unless (c-forward-type) (throw 'break nil))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6211 (when (eq start-char ?\()
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6212 (unless (eq (char-after) ?\)) (throw 'break nil))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6213 (forward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6214 (c-forward-syntactic-ws)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6215
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6216 ;; Look for a protocol reference list.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6217 (if (eq (char-after) ?<)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6218 (let ((c-recognize-<>-arglists t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6219 (c-parse-and-markup-<>-arglists t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6220 c-restricted-<>-arglists)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6221 (c-forward-<>-arglist t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6222 t))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6223
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6224 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6225 (c-backward-syntactic-ws)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6226 (c-clear-c-type-property start (1- (point)) 'c-decl-end)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6227 (c-put-c-type-property (1- (point)) 'c-decl-end)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6228 t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6229
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6230 (c-clear-c-type-property start (point) 'c-decl-end)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6231 nil)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6232
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6233 (defun c-beginning-of-inheritance-list (&optional lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6234 ;; Go to the first non-whitespace after the colon that starts a
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6235 ;; multiple inheritance introduction. Optional LIM is the farthest
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6236 ;; back we should search.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6237 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6238 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6239 (c-with-syntax-table c++-template-syntax-table
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6240 (c-backward-token-2 0 t lim)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6241 (while (and (or (looking-at c-symbol-start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6242 (looking-at "[<,]\\|::"))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6243 (zerop (c-backward-token-2 1 t lim))))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6244
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6245 (defun c-in-method-def-p ()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6246 ;; Return nil if we aren't in a method definition, otherwise the
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6247 ;; position of the initial [+-].
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6248 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6249 ;; This function might do hidden buffer changes.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6250 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6251 (beginning-of-line)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6252 (and c-opt-method-key
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6253 (looking-at c-opt-method-key)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6254 (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6255 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6256
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6257 ;; Contributed by Kevin Ryde <user42@zip.com.au>.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6258 (defun c-in-gcc-asm-p ()
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6259 ;; Return non-nil if point is within a gcc \"asm\" block.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6260 ;;
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6261 ;; This should be called with point inside an argument list.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6262 ;;
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6263 ;; Only one level of enclosing parentheses is considered, so for
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6264 ;; instance `nil' is returned when in a function call within an asm
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6265 ;; operand.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6266 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6267 ;; This function might do hidden buffer changes.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6268
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6269 (and c-opt-asm-stmt-key
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6270 (save-excursion
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6271 (beginning-of-line)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6272 (backward-up-list 1)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6273 (c-beginning-of-statement-1 (point-min) nil t)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6274 (looking-at c-opt-asm-stmt-key))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6275
24335
0c4688f9a396 Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents: 24282
diff changeset
6276 (defun c-at-toplevel-p ()
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
6277 "Return a determination as to whether point is \"at the top level\".
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
6278 Informally, \"at the top level\" is anywhere where you can write
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
6279 a function.
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
6280
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
6281 More precisely, being at the top-level means that point is either
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
6282 outside any enclosing block (such as a function definition), or
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
6283 directly inside a class, namespace or other block that contains
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
6284 another declaration level.
24335
0c4688f9a396 Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents: 24282
diff changeset
6285
0c4688f9a396 Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents: 24282
diff changeset
6286 If point is not at the top-level (e.g. it is inside a method
0c4688f9a396 Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents: 24282
diff changeset
6287 definition), then nil is returned. Otherwise, if point is at a
0c4688f9a396 Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents: 24282
diff changeset
6288 top-level not enclosed within a class definition, t is returned.
0c4688f9a396 Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents: 24282
diff changeset
6289 Otherwise, a 2-vector is returned where the zeroth element is the
0c4688f9a396 Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents: 24282
diff changeset
6290 buffer position of the start of the class declaration, and the first
0c4688f9a396 Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents: 24282
diff changeset
6291 element is the buffer position of the enclosing class's opening
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6292 brace.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6293
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6294 Note that this function might do hidden buffer changes. See the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6295 comment at the start of cc-engine.el for more info."
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6296 (let ((paren-state (c-parse-state)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6297 (or (not (c-most-enclosing-brace paren-state))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6298 (c-search-uplist-for-classkey paren-state))))
24335
0c4688f9a396 Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents: 24282
diff changeset
6299
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6300 (defun c-just-after-func-arglist-p (&optional lim)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6301 ;; Return non-nil if the point is in the region after the argument
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6302 ;; list of a function and its opening brace (or semicolon in case it
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6303 ;; got no body). If there are K&R style argument declarations in
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6304 ;; that region, the point has to be inside the first one for this
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6305 ;; function to recognize it.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6306 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6307 ;; If successful, the point is moved to the first token after the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6308 ;; function header (see `c-forward-decl-or-cast-1' for details) and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6309 ;; the position of the opening paren of the function arglist is
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6310 ;; returned.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6311 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6312 ;; The point is clobbered if not successful.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6313 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6314 ;; LIM is used as bound for backward buffer searches.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6315 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6316 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6317
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6318 (let ((beg (point)) end id-start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6319 (and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6320 (eq (c-beginning-of-statement-1 lim) 'same)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6321
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6322 (not (or (c-major-mode-is 'objc-mode)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6323 (c-forward-objc-directive)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6324
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6325 (setq id-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6326 (car-safe (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6327 (< id-start beg)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6328
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6329 ;; There should not be a '=' or ',' between beg and the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6330 ;; start of the declaration since that means we were in the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6331 ;; "expression part" of the declaration.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6332 (or (> (point) beg)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6333 (not (looking-at "[=,]")))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6334
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6335 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6336 ;; Check that there's an arglist paren in the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6337 ;; declaration.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6338 (goto-char id-start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6339 (cond ((eq (char-after) ?\()
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6340 ;; The declarator is a paren expression, so skip past it
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6341 ;; so that we don't get stuck on that instead of the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6342 ;; function arglist.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6343 (c-forward-sexp))
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6344 ((and c-opt-op-identifier-prefix
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6345 (looking-at c-opt-op-identifier-prefix))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6346 ;; Don't trip up on "operator ()".
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6347 (c-forward-token-2 2 t)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6348 (and (< (point) beg)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6349 (c-syntactic-re-search-forward "(" beg t t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6350 (1- (point)))))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6351
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6352 (defun c-in-knr-argdecl (&optional lim)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6353 ;; Return the position of the first argument declaration if point is
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6354 ;; inside a K&R style argument declaration list, nil otherwise.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6355 ;; `c-recognize-knr-p' is not checked. If LIM is non-nil, it's a
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6356 ;; position that bounds the backward search for the argument list.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6357 ;;
75315
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6358 ;; Point must be within a possible K&R region, e.g. just before a top-level
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6359 ;; "{". It must be outside of parens and brackets. The test can return
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6360 ;; false positives otherwise.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6361 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6362 ;; This function might do hidden buffer changes.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6363
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6364 (save-excursion
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6365 (save-restriction
75315
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6366 ;; If we're in a macro, our search range is restricted to it. Narrow to
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6367 ;; the searchable range.
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6368 (let* ((macro-start (c-query-macro-start))
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6369 (lim (max (or lim (point-min)) (or macro-start (point-min))))
92572
897b09fb6e10 (c-in-knr-argdecl): Limit number of paren/bracket pairs parsed, to solve
Alan Mackenzie <acm@muc.de>
parents: 92148
diff changeset
6370 before-lparen after-rparen
897b09fb6e10 (c-in-knr-argdecl): Limit number of paren/bracket pairs parsed, to solve
Alan Mackenzie <acm@muc.de>
parents: 92148
diff changeset
6371 (pp-count-out 20)) ; Max number of paren/brace constructs before we give up
75315
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6372 (narrow-to-region lim (c-point 'eol))
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6373
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6374 ;; Search backwards for the defun's argument list. We give up if we
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6375 ;; encounter a "}" (end of a previous defun) or BOB.
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6376 ;;
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6377 ;; The criterion for a paren structure being the arg list is:
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6378 ;; o - there is non-WS stuff after it but before any "{"; AND
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6379 ;; o - the token after it isn't a ";" AND
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6380 ;; o - it is preceded by either an identifier (the function name) or
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6381 ;; a macro expansion like "DEFUN (...)"; AND
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6382 ;; o - its content is a non-empty comma-separated list of identifiers
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6383 ;; (an empty arg list won't have a knr region).
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6384 ;;
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6385 ;; The following snippet illustrates these rules:
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6386 ;; int foo (bar, baz, yuk)
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6387 ;; int bar [] ;
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6388 ;; int (*baz) (my_type) ;
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6389 ;; int (*) (void) (*yuk) (void) ;
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6390 ;; {
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6391
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6392 (catch 'knr
92572
897b09fb6e10 (c-in-knr-argdecl): Limit number of paren/bracket pairs parsed, to solve
Alan Mackenzie <acm@muc.de>
parents: 92148
diff changeset
6393 (while (> pp-count-out 0) ; go back one paren/bracket pair each time.
897b09fb6e10 (c-in-knr-argdecl): Limit number of paren/bracket pairs parsed, to solve
Alan Mackenzie <acm@muc.de>
parents: 92148
diff changeset
6394 (setq pp-count-out (1- pp-count-out))
75623
33cf1027eb42 (c-in-knr-argdecl): Slight correction for, e.g. "void (*hdone)();" in a
Alan Mackenzie <acm@muc.de>
parents: 75347
diff changeset
6395 (c-syntactic-skip-backward "^)]}")
75315
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6396 (cond ((eq (char-before) ?\))
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6397 (setq after-rparen (point)))
75623
33cf1027eb42 (c-in-knr-argdecl): Slight correction for, e.g. "void (*hdone)();" in a
Alan Mackenzie <acm@muc.de>
parents: 75347
diff changeset
6398 ((eq (char-before) ?\])
33cf1027eb42 (c-in-knr-argdecl): Slight correction for, e.g. "void (*hdone)();" in a
Alan Mackenzie <acm@muc.de>
parents: 75347
diff changeset
6399 (setq after-rparen nil))
33cf1027eb42 (c-in-knr-argdecl): Slight correction for, e.g. "void (*hdone)();" in a
Alan Mackenzie <acm@muc.de>
parents: 75347
diff changeset
6400 (t ; either } (hit previous defun) or no more parens/brackets
33cf1027eb42 (c-in-knr-argdecl): Slight correction for, e.g. "void (*hdone)();" in a
Alan Mackenzie <acm@muc.de>
parents: 75347
diff changeset
6401 (throw 'knr nil)))
75315
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6402
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6403 (if after-rparen
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6404 ;; We're inside a paren. Could it be our argument list....?
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6405 (if
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6406 (and
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6407 (progn
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6408 (goto-char after-rparen)
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6409 (unless (c-go-list-backward) (throw 'knr nil)) ;
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6410 ;; FIXME!!! What about macros between the parens? 2007/01/20
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6411 (setq before-lparen (point)))
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6412
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6413 ;; It can't be the arg list if next token is ; or {
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6414 (progn (goto-char after-rparen)
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6415 (c-forward-syntactic-ws)
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6416 (not (memq (char-after) '(?\; ?\{))))
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6417
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6418 ;; Is the thing preceding the list an identifier (the
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6419 ;; function name), or a macro expansion?
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6420 (progn
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6421 (goto-char before-lparen)
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6422 (eq (c-backward-token-2) 0)
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6423 (or (c-on-identifier)
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6424 (and (eq (char-after) ?\))
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6425 (c-go-up-list-backward)
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6426 (eq (c-backward-token-2) 0)
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6427 (c-on-identifier))))
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6428
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6429 ;; Have we got a non-empty list of comma-separated
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6430 ;; identifiers?
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6431 (progn
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6432 (goto-char before-lparen)
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6433 (c-forward-token-2) ; to first token inside parens
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6434 (and
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6435 (c-on-identifier)
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6436 (c-forward-token-2)
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6437 (catch 'id-list
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6438 (while (eq (char-after) ?\,)
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6439 (c-forward-token-2)
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6440 (unless (c-on-identifier) (throw 'id-list nil))
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6441 (c-forward-token-2))
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6442 (eq (char-after) ?\))))))
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6443
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6444 ;; ...Yes. We've identified the function's argument list.
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6445 (throw 'knr
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6446 (progn (goto-char after-rparen)
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6447 (c-forward-syntactic-ws)
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6448 (point)))
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6449
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6450 ;; ...No. The current parens aren't the function's arg list.
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6451 (goto-char before-lparen))
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6452
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6453 (or (c-go-list-backward) ; backwards over [ .... ]
656ff90fee33 Reformulate c-in-knr-argdecl to do much more rigorous analysis of
Alan Mackenzie <acm@muc.de>
parents: 75307
diff changeset
6454 (throw 'knr nil)))))))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6455
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6456 (defun c-skip-conditional ()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6457 ;; skip forward over conditional at point, including any predicate
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6458 ;; statements in parentheses. No error checking is performed.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6459 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6460 ;; This function might do hidden buffer changes.
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6461 (c-forward-sexp (cond
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6462 ;; else if()
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6463 ((looking-at (concat "\\<else"
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6464 "\\([ \t\n]\\|\\\\\n\\)+"
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6465 "if\\>\\([^_]\\|$\\)"))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6466 3)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6467 ;; do, else, try, finally
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6468 ((looking-at (concat "\\<\\("
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6469 "do\\|else\\|try\\|finally"
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6470 "\\)\\>\\([^_]\\|$\\)"))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
6471 1)
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
6472 ;; for, if, while, switch, catch, synchronized, foreach
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6473 (t 2))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6474
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6475 (defun c-after-conditional (&optional lim)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6476 ;; If looking at the token after a conditional then return the
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6477 ;; position of its start, otherwise return nil.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6478 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6479 ;; This function might do hidden buffer changes.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6480 (save-excursion
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6481 (and (zerop (c-backward-token-2 1 t lim))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6482 (or (looking-at c-block-stmt-1-key)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6483 (and (eq (char-after) ?\()
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6484 (zerop (c-backward-token-2 1 t lim))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6485 (looking-at c-block-stmt-2-key)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6486 (point))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6487
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6488 (defun c-after-special-operator-id (&optional lim)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6489 ;; If the point is after an operator identifier that isn't handled
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6490 ;; like an ordinary symbol (i.e. like "operator =" in C++) then the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6491 ;; position of the start of that identifier is returned. nil is
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6492 ;; returned otherwise. The point may be anywhere in the syntactic
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6493 ;; whitespace after the last token of the operator identifier.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6494 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6495 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6496 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6497 (and c-overloadable-operators-regexp
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6498 (zerop (c-backward-token-2 1 nil lim))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6499 (looking-at c-overloadable-operators-regexp)
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6500 (or (not c-opt-op-identifier-prefix)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6501 (and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6502 (zerop (c-backward-token-2 1 nil lim))
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6503 (looking-at c-opt-op-identifier-prefix)))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6504 (point))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6505
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6506 (defsubst c-backward-to-block-anchor (&optional lim)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6507 ;; Assuming point is at a brace that opens a statement block of some
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6508 ;; kind, move to the proper anchor point for that block. It might
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6509 ;; need to be adjusted further by c-add-stmt-syntax, but the
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6510 ;; position at return is suitable as start position for that
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6511 ;; function.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6512 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6513 ;; This function might do hidden buffer changes.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6514 (unless (= (point) (c-point 'boi))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6515 (let ((start (c-after-conditional lim)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6516 (if start
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6517 (goto-char start)))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6518
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
6519 (defsubst c-backward-to-decl-anchor (&optional lim)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6520 ;; Assuming point is at a brace that opens the block of a top level
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6521 ;; declaration of some kind, move to the proper anchor point for
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6522 ;; that block.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6523 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6524 ;; This function might do hidden buffer changes.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6525 (unless (= (point) (c-point 'boi))
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
6526 (c-beginning-of-statement-1 lim)))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6527
52107
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6528 (defun c-search-decl-header-end ()
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6529 ;; Search forward for the end of the "header" of the current
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6530 ;; declaration. That's the position where the definition body
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6531 ;; starts, or the first variable initializer, or the ending
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6532 ;; semicolon. I.e. search forward for the closest following
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6533 ;; (syntactically relevant) '{', '=' or ';' token. Point is left
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6534 ;; _after_ the first found token, or at point-max if none is found.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6535 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6536 ;; This function might do hidden buffer changes.
52107
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6537
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6538 (let ((base (point)))
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6539 (if (c-major-mode-is 'c++-mode)
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6540
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6541 ;; In C++ we need to take special care to handle operator
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6542 ;; tokens and those pesky template brackets.
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6543 (while (and
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6544 (c-syntactic-re-search-forward "[;{<=]" nil 'move t t)
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6545 (or
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6546 (c-end-of-current-token base)
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6547 ;; Handle operator identifiers, i.e. ignore any
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6548 ;; operator token preceded by "operator".
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6549 (save-excursion
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6550 (and (c-safe (c-backward-sexp) t)
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6551 (looking-at c-opt-op-identifier-prefix)))
52107
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6552 (and (eq (char-before) ?<)
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6553 (c-with-syntax-table c++-template-syntax-table
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6554 (if (c-safe (goto-char (c-up-list-forward (point))))
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6555 t
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6556 (goto-char (point-max))
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6557 nil)))))
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6558 (setq base (point)))
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6559
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6560 (while (and
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6561 (c-syntactic-re-search-forward "[;{=]" nil 'move t t)
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6562 (c-end-of-current-token base))
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
6563 (setq base (point))))))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6564
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6565 (defun c-beginning-of-decl-1 (&optional lim)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6566 ;; Go to the beginning of the current declaration, or the beginning
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6567 ;; of the previous one if already at the start of it. Point won't
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6568 ;; be moved out of any surrounding paren. Return a cons cell of the
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6569 ;; form (MOVE . KNR-POS). MOVE is like the return value from
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6570 ;; `c-beginning-of-statement-1'. If point skipped over some K&R
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6571 ;; style argument declarations (and they are to be recognized) then
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6572 ;; KNR-POS is set to the start of the first such argument
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6573 ;; declaration, otherwise KNR-POS is nil. If LIM is non-nil, it's a
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6574 ;; position that bounds the backward search.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6575 ;;
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6576 ;; NB: Cases where the declaration continues after the block, as in
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6577 ;; "struct foo { ... } bar;", are currently recognized as two
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6578 ;; declarations, e.g. "struct foo { ... }" and "bar;" in this case.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6579 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6580 ;; This function might do hidden buffer changes.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6581 (catch 'return
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6582 (let* ((start (point))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6583 (last-stmt-start (point))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6584 (move (c-beginning-of-statement-1 lim nil t)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6585
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6586 ;; `c-beginning-of-statement-1' stops at a block start, but we
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6587 ;; want to continue if the block doesn't begin a top level
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
6588 ;; construct, i.e. if it isn't preceded by ';', '}', ':', bob,
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
6589 ;; or an open paren.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6590 (let ((beg (point)) tentative-move)
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6591 ;; Go back one "statement" each time round the loop until we're just
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6592 ;; after a ;, }, or :, or at BOB or the start of a macro or start of
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6593 ;; an ObjC method. This will move over a multiple declaration whose
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6594 ;; components are comma separated.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6595 (while (and
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6596 ;; Must check with c-opt-method-key in ObjC mode.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6597 (not (and c-opt-method-key
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6598 (looking-at c-opt-method-key)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6599 (/= last-stmt-start (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6600 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6601 (c-backward-syntactic-ws lim)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6602 (not (memq (char-before) '(?\; ?} ?: nil))))
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
6603 (save-excursion
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
6604 (backward-char)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
6605 (not (looking-at "\\s(")))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6606 ;; Check that we don't move from the first thing in a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6607 ;; macro to its header.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6608 (not (eq (setq tentative-move
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6609 (c-beginning-of-statement-1 lim nil t))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6610 'macro)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6611 (setq last-stmt-start beg
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6612 beg (point)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6613 move tentative-move))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6614 (goto-char beg))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6615
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6616 (when c-recognize-knr-p
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6617 (let ((fallback-pos (point)) knr-argdecl-start)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6618 ;; Handle K&R argdecls. Back up after the "statement" jumped
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6619 ;; over by `c-beginning-of-statement-1', unless it was the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6620 ;; function body, in which case we're sitting on the opening
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6621 ;; brace now. Then test if we're in a K&R argdecl region and
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6622 ;; that we started at the other side of the first argdecl in
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6623 ;; it.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6624 (unless (eq (char-after) ?{)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6625 (goto-char last-stmt-start))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6626 (if (and (setq knr-argdecl-start (c-in-knr-argdecl lim))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6627 (< knr-argdecl-start start)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6628 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6629 (goto-char knr-argdecl-start)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6630 (not (eq (c-beginning-of-statement-1 lim nil t) 'macro))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6631 (throw 'return
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6632 (cons (if (eq (char-after fallback-pos) ?{)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6633 'previous
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6634 'same)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6635 knr-argdecl-start))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6636 (goto-char fallback-pos))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6637
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6638 ;; `c-beginning-of-statement-1' counts each brace block as a separate
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6639 ;; statement, so the result will be 'previous if we've moved over any.
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6640 ;; So change our result back to 'same if necessary.
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6641 ;;
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6642 ;; If they were brace list initializers we might not have moved over a
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6643 ;; declaration boundary though, so change it to 'same if we've moved
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6644 ;; past a '=' before '{', but not ';'. (This ought to be integrated
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6645 ;; into `c-beginning-of-statement-1', so we avoid this extra pass which
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6646 ;; potentially can search over a large amount of text.). Take special
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6647 ;; pains not to get mislead by C++'s "operator=", and the like.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6648 (if (and (eq move 'previous)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6649 (c-with-syntax-table (if (c-major-mode-is 'c++-mode)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6650 c++-template-syntax-table
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6651 (syntax-table))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6652 (save-excursion
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6653 (and
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6654 (progn
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6655 (while ; keep going back to "[;={"s until we either find
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6656 ; no more, or get to one which isn't an "operator ="
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6657 (and (c-syntactic-re-search-forward "[;={]" start t t t)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6658 (eq (char-before) ?=)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6659 c-overloadable-operators-regexp
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6660 c-opt-op-identifier-prefix
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6661 (save-excursion
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6662 (eq (c-backward-token-2) 0)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6663 (looking-at c-overloadable-operators-regexp)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6664 (eq (c-backward-token-2) 0)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6665 (looking-at c-opt-op-identifier-prefix))))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6666 (eq (char-before) ?=))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6667 (c-syntactic-re-search-forward "[;{]" start t t)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6668 (eq (char-before) ?{)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6669 (c-safe (goto-char (c-up-list-forward (point))) t)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6670 (not (c-syntactic-re-search-forward ";" start t t))))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6671 (cons 'same nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6672 (cons move nil)))))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6673
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6674 (defun c-end-of-decl-1 ()
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6675 ;; Assuming point is at the start of a declaration (as detected by
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6676 ;; e.g. `c-beginning-of-decl-1'), go to the end of it. Unlike
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6677 ;; `c-beginning-of-decl-1', this function handles the case when a
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6678 ;; block is followed by identifiers in e.g. struct declarations in C
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6679 ;; or C++. If a proper end was found then t is returned, otherwise
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6680 ;; point is moved as far as possible within the current sexp and nil
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6681 ;; is returned. This function doesn't handle macros; use
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6682 ;; `c-end-of-macro' instead in those cases.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6683 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6684 ;; This function might do hidden buffer changes.
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
6685 (let ((start (point))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6686 (decl-syntax-table (if (c-major-mode-is 'c++-mode)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6687 c++-template-syntax-table
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6688 (syntax-table))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6689 (catch 'return
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6690 (c-search-decl-header-end)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6691
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6692 (when (and c-recognize-knr-p
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6693 (eq (char-before) ?\;)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6694 (c-in-knr-argdecl start))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6695 ;; Stopped at the ';' in a K&R argdecl section which is
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6696 ;; detected using the same criteria as in
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6697 ;; `c-beginning-of-decl-1'. Move to the following block
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6698 ;; start.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6699 (c-syntactic-re-search-forward "{" nil 'move t))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6700
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6701 (when (eq (char-before) ?{)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6702 ;; Encountered a block in the declaration. Jump over it.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6703 (condition-case nil
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6704 (goto-char (c-up-list-forward (point)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6705 (error (goto-char (point-max))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6706 (throw 'return nil)))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6707 (if (or (not c-opt-block-decls-with-vars-key)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6708 (save-excursion
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6709 (c-with-syntax-table decl-syntax-table
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6710 (let ((lim (point)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6711 (goto-char start)
45049
11c11cb2b8a8 (c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents: 44728
diff changeset
6712 (not (and
11c11cb2b8a8 (c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents: 44728
diff changeset
6713 ;; Check for `c-opt-block-decls-with-vars-key'
11c11cb2b8a8 (c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents: 44728
diff changeset
6714 ;; before the first paren.
11c11cb2b8a8 (c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents: 44728
diff changeset
6715 (c-syntactic-re-search-forward
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6716 (concat "[;=\(\[{]\\|\\("
45049
11c11cb2b8a8 (c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents: 44728
diff changeset
6717 c-opt-block-decls-with-vars-key
11c11cb2b8a8 (c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents: 44728
diff changeset
6718 "\\)")
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6719 lim t t t)
45049
11c11cb2b8a8 (c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents: 44728
diff changeset
6720 (match-beginning 1)
11c11cb2b8a8 (c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents: 44728
diff changeset
6721 (not (eq (char-before) ?_))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6722 ;; Check that the first following paren is
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6723 ;; the block.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6724 (c-syntactic-re-search-forward "[;=\(\[{]"
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6725 lim t t t)
45049
11c11cb2b8a8 (c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents: 44728
diff changeset
6726 (eq (char-before) ?{)))))))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6727 ;; The declaration doesn't have any of the
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6728 ;; `c-opt-block-decls-with-vars' keywords in the
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6729 ;; beginning, so it ends here at the end of the block.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6730 (throw 'return t)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6731
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6732 (c-with-syntax-table decl-syntax-table
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6733 (while (progn
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6734 (if (eq (char-before) ?\;)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6735 (throw 'return t))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6736 (c-syntactic-re-search-forward ";" nil 'move t))))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6737 nil)))
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
6738
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6739 (defun c-looking-at-decl-block (containing-sexp goto-start &optional limit)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6740 ;; Assuming the point is at an open brace, check if it starts a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6741 ;; block that contains another declaration level, i.e. that isn't a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6742 ;; statement block or a brace list, and if so return non-nil.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6743 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6744 ;; If the check is successful, the return value is the start of the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6745 ;; keyword that tells what kind of construct it is, i.e. typically
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6746 ;; what `c-decl-block-key' matched. Also, if GOTO-START is set then
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6747 ;; the point will be at the start of the construct, before any
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6748 ;; leading specifiers, otherwise it's at the returned position.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6749 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6750 ;; The point is clobbered if the check is unsuccessful.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6751 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6752 ;; CONTAINING-SEXP is the position of the open of the surrounding
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6753 ;; paren, or nil if none.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6754 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6755 ;; The optional LIMIT limits the backward search for the start of
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6756 ;; the construct. It's assumed to be at a syntactically relevant
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6757 ;; position.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6758 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6759 ;; If any template arglists are found in the searched region before
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6760 ;; the open brace, they get marked with paren syntax.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6761 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6762 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6763
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6764 (let ((open-brace (point)) kwd-start first-specifier-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6765 (c-syntactic-skip-backward c-block-prefix-charset limit t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6766
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6767 (when (and c-recognize-<>-arglists
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6768 (eq (char-before) ?>))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6769 ;; Could be at the end of a template arglist.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6770 (let ((c-parse-and-markup-<>-arglists t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6771 (c-disallow-comma-in-<>-arglists
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6772 (and containing-sexp
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6773 (not (eq (char-after containing-sexp) ?{)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6774 (while (and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6775 (c-backward-<>-arglist nil limit)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6776 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6777 (c-syntactic-skip-backward c-block-prefix-charset limit t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6778 (eq (char-before) ?>))))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6779
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6780 ;; Note: Can't get bogus hits inside template arglists below since they
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6781 ;; have gotten paren syntax above.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6782 (when (and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6783 ;; If `goto-start' is set we begin by searching for the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6784 ;; first possible position of a leading specifier list.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6785 ;; The `c-decl-block-key' search continues from there since
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6786 ;; we know it can't match earlier.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6787 (if goto-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6788 (when (c-syntactic-re-search-forward c-symbol-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6789 open-brace t t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6790 (goto-char (setq first-specifier-pos (match-beginning 0)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6791 t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6792 t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6793
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6794 (cond
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6795 ((c-syntactic-re-search-forward c-decl-block-key open-brace t t t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6796 (goto-char (setq kwd-start (match-beginning 0)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6797 (or
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6798
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6799 ;; Found a keyword that can't be a type?
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6800 (match-beginning 1)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6801
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6802 ;; Can be a type too, in which case it's the return type of a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6803 ;; function (under the assumption that no declaration level
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6804 ;; block construct starts with a type).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6805 (not (c-forward-type))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6806
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6807 ;; Jumped over a type, but it could be a declaration keyword
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6808 ;; followed by the declared identifier that we've jumped over
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6809 ;; instead (e.g. in "class Foo {"). If it indeed is a type
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6810 ;; then we should be at the declarator now, so check for a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6811 ;; valid declarator start.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6812 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6813 ;; Note: This doesn't cope with the case when a declared
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6814 ;; identifier is followed by e.g. '(' in a language where '('
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6815 ;; also might be part of a declarator expression. Currently
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6816 ;; there's no such language.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6817 (not (or (looking-at c-symbol-start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6818 (looking-at c-type-decl-prefix-key)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6819
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6820 ;; In Pike a list of modifiers may be followed by a brace
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6821 ;; to make them apply to many identifiers. Note that the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6822 ;; match data will be empty on return in this case.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6823 ((and (c-major-mode-is 'pike-mode)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6824 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6825 (goto-char open-brace)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6826 (= (c-backward-token-2) 0))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6827 (looking-at c-specifier-key)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6828 ;; Use this variant to avoid yet another special regexp.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6829 (c-keyword-member (c-keyword-sym (match-string 1))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6830 'c-modifier-kwds))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6831 (setq kwd-start (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6832 t)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6833
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6834 ;; Got a match.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6835
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6836 (if goto-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6837 ;; Back up over any preceding specifiers and their clauses
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6838 ;; by going forward from `first-specifier-pos', which is the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6839 ;; earliest possible position where the specifier list can
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6840 ;; start.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6841 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6842 (goto-char first-specifier-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6843
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6844 (while (< (point) kwd-start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6845 (if (looking-at c-symbol-key)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6846 ;; Accept any plain symbol token on the ground that
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6847 ;; it's a specifier masked through a macro (just
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6848 ;; like `c-forward-decl-or-cast-1' skip forward over
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6849 ;; such tokens).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6850 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6851 ;; Could be more restrictive wrt invalid keywords,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6852 ;; but that'd only occur in invalid code so there's
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6853 ;; no use spending effort on it.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6854 (let ((end (match-end 0)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6855 (unless (c-forward-keyword-clause 0)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6856 (goto-char end)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6857 (c-forward-syntactic-ws)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6858
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6859 ;; Can't parse a declaration preamble and is still
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6860 ;; before `kwd-start'. That means `first-specifier-pos'
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6861 ;; was in some earlier construct. Search again.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6862 (if (c-syntactic-re-search-forward c-symbol-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6863 kwd-start 'move t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6864 (goto-char (setq first-specifier-pos (match-beginning 0)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6865 ;; Got no preamble before the block declaration keyword.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6866 (setq first-specifier-pos kwd-start))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6867
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6868 (goto-char first-specifier-pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6869 (goto-char kwd-start))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6870
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6871 kwd-start)))
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
6872
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6873 (defun c-search-uplist-for-classkey (paren-state)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6874 ;; Check if the closest containing paren sexp is a declaration
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6875 ;; block, returning a 2 element vector in that case. Aref 0
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6876 ;; contains the bufpos at boi of the class key line, and aref 1
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6877 ;; contains the bufpos of the open brace. This function is an
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6878 ;; obsolete wrapper for `c-looking-at-decl-block'.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6879 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6880 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6881 (let ((open-paren-pos (c-most-enclosing-brace paren-state)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6882 (when open-paren-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6883 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6884 (goto-char open-paren-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6885 (when (and (eq (char-after) ?{)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6886 (c-looking-at-decl-block
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6887 (c-safe-position open-paren-pos paren-state)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6888 nil))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6889 (back-to-indentation)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6890 (vector (point) open-paren-pos))))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6891
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6892 (defun c-inside-bracelist-p (containing-sexp paren-state)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6893 ;; return the buffer position of the beginning of the brace list
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6894 ;; statement if we're inside a brace list, otherwise return nil.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6895 ;; CONTAINING-SEXP is the buffer pos of the innermost containing
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6896 ;; paren. PAREN-STATE is the remainder of the state of enclosing
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
6897 ;; braces
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6898 ;;
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6899 ;; N.B.: This algorithm can potentially get confused by cpp macros
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6900 ;; placed in inconvenient locations. It's a trade-off we make for
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6901 ;; speed.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6902 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6903 ;; This function might do hidden buffer changes.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6904 (or
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6905 ;; This will pick up brace list declarations.
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
6906 (c-safe
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
6907 (save-excursion
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
6908 (goto-char containing-sexp)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6909 (c-forward-sexp -1)
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
6910 (let (bracepos)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6911 (if (and (or (looking-at c-brace-list-key)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6912 (progn (c-forward-sexp -1)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6913 (looking-at c-brace-list-key)))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6914 (setq bracepos (c-down-list-forward (point)))
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
6915 (not (c-crosses-statement-barrier-p (point)
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
6916 (- bracepos 2))))
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
6917 (point)))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6918 ;; this will pick up array/aggregate init lists, even if they are nested.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6919 (save-excursion
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6920 (let ((class-key
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6921 ;; Pike can have class definitions anywhere, so we must
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6922 ;; check for the class key here.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6923 (and (c-major-mode-is 'pike-mode)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6924 c-decl-block-key))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6925 bufpos braceassignp lim next-containing)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6926 (while (and (not bufpos)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6927 containing-sexp)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6928 (when paren-state
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6929 (if (consp (car paren-state))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6930 (setq lim (cdr (car paren-state))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6931 paren-state (cdr paren-state))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6932 (setq lim (car paren-state)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6933 (when paren-state
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6934 (setq next-containing (car paren-state)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6935 paren-state (cdr paren-state))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
6936 (goto-char containing-sexp)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6937 (if (c-looking-at-inexpr-block next-containing next-containing)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6938 ;; We're in an in-expression block of some kind. Do not
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6939 ;; check nesting. We deliberately set the limit to the
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6940 ;; containing sexp, so that c-looking-at-inexpr-block
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6941 ;; doesn't check for an identifier before it.
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6942 (setq containing-sexp nil)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6943 ;; see if the open brace is preceded by = or [...] in
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6944 ;; this statement, but watch out for operator=
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6945 (setq braceassignp 'dontknow)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6946 (c-backward-token-2 1 t lim)
25178
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
6947 ;; Checks to do only on the first sexp before the brace.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6948 (when (and c-opt-inexpr-brace-list-key
25178
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
6949 (eq (char-after) ?\[))
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
6950 ;; In Java, an initialization brace list may follow
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
6951 ;; directly after "new Foo[]", so check for a "new"
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
6952 ;; earlier.
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
6953 (while (eq braceassignp 'dontknow)
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
6954 (setq braceassignp
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6955 (cond ((/= (c-backward-token-2 1 t lim) 0) nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6956 ((looking-at c-opt-inexpr-brace-list-key) t)
25178
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
6957 ((looking-at "\\sw\\|\\s_\\|[.[]")
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
6958 ;; Carry on looking if this is an
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
6959 ;; identifier (may contain "." in Java)
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
6960 ;; or another "[]" sexp.
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
6961 'dontknow)
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
6962 (t nil)))))
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
6963 ;; Checks to do on all sexps before the brace, up to the
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
6964 ;; beginning of the statement.
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
6965 (while (eq braceassignp 'dontknow)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6966 (cond ((eq (char-after) ?\;)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6967 (setq braceassignp nil))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6968 ((and class-key
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6969 (looking-at class-key))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6970 (setq braceassignp nil))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6971 ((eq (char-after) ?=)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6972 ;; We've seen a =, but must check earlier tokens so
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6973 ;; that it isn't something that should be ignored.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6974 (setq braceassignp 'maybe)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6975 (while (and (eq braceassignp 'maybe)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
6976 (zerop (c-backward-token-2 1 t lim)))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6977 (setq braceassignp
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6978 (cond
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6979 ;; Check for operator =
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6980 ((and c-opt-op-identifier-prefix
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
6981 (looking-at c-opt-op-identifier-prefix))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
6982 nil)
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
6983 ;; Check for `<opchar>= in Pike.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
6984 ((and (c-major-mode-is 'pike-mode)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
6985 (or (eq (char-after) ?`)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
6986 ;; Special case for Pikes
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
6987 ;; `[]=, since '[' is not in
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
6988 ;; the punctuation class.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
6989 (and (eq (char-after) ?\[)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
6990 (eq (char-before) ?`))))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
6991 nil)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6992 ((looking-at "\\s.") 'maybe)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6993 ;; make sure we're not in a C++ template
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
6994 ;; argument assignment
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6995 ((and
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6996 (c-major-mode-is 'c++-mode)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6997 (save-excursion
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6998 (let ((here (point))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
6999 (pos< (progn
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7000 (skip-chars-backward "^<>")
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7001 (point))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7002 (and (eq (char-before) ?<)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7003 (not (c-crosses-statement-barrier-p
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7004 pos< here))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7005 (not (c-in-literal))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7006 ))))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7007 nil)
25178
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
7008 (t t))))))
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
7009 (if (and (eq braceassignp 'dontknow)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7010 (/= (c-backward-token-2 1 t lim) 0))
25178
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
7011 (setq braceassignp nil)))
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
7012 (if (not braceassignp)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7013 (if (eq (char-after) ?\;)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7014 ;; Brace lists can't contain a semicolon, so we're done.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7015 (setq containing-sexp nil)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7016 ;; Go up one level.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7017 (setq containing-sexp next-containing
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7018 lim nil
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7019 next-containing nil))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7020 ;; we've hit the beginning of the aggregate list
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7021 (c-beginning-of-statement-1
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7022 (c-most-enclosing-brace paren-state))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7023 (setq bufpos (point))))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7024 )
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7025 bufpos))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7026 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7027
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7028 (defun c-looking-at-special-brace-list (&optional lim)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7029 ;; If we're looking at the start of a pike-style list, ie `({ })',
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
7030 ;; `([ ])', `(< >)' etc, a cons of a cons of its starting and ending
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7031 ;; positions and its entry in c-special-brace-lists is returned, nil
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7032 ;; otherwise. The ending position is nil if the list is still open.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7033 ;; LIM is the limit for forward search. The point may either be at
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7034 ;; the `(' or at the following paren character. Tries to check the
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7035 ;; matching closer, but assumes it's correct if no balanced paren is
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7036 ;; found (i.e. the case `({ ... } ... )' is detected as _not_ being
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7037 ;; a special brace list).
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7038 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7039 ;; This function might do hidden buffer changes.
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7040 (if c-special-brace-lists
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7041 (condition-case ()
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7042 (save-excursion
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7043 (let ((beg (point))
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7044 inner-beg end type)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7045 (c-forward-syntactic-ws)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7046 (if (eq (char-after) ?\()
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7047 (progn
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7048 (forward-char 1)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7049 (c-forward-syntactic-ws)
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7050 (setq inner-beg (point))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7051 (setq type (assq (char-after) c-special-brace-lists)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7052 (if (setq type (assq (char-after) c-special-brace-lists))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7053 (progn
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7054 (setq inner-beg (point))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7055 (c-backward-syntactic-ws)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7056 (forward-char -1)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7057 (setq beg (if (eq (char-after) ?\()
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7058 (point)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7059 nil)))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7060 (if (and beg type)
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7061 (if (and (c-safe
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7062 (goto-char beg)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7063 (c-forward-sexp 1)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7064 (setq end (point))
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7065 (= (char-before) ?\)))
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7066 (c-safe
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7067 (goto-char inner-beg)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7068 (if (looking-at "\\s(")
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7069 ;; Check balancing of the inner paren
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7070 ;; below.
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7071 (progn
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7072 (c-forward-sexp 1)
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7073 t)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7074 ;; If the inner char isn't a paren then
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7075 ;; we can't check balancing, so just
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7076 ;; check the char before the outer
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7077 ;; closing paren.
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7078 (goto-char end)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7079 (backward-char)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7080 (c-backward-syntactic-ws)
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
7081 (= (char-before) (cdr type)))))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7082 (if (or (/= (char-syntax (char-before)) ?\))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7083 (= (progn
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7084 (c-forward-syntactic-ws)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7085 (point))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7086 (1- end)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7087 (cons (cons beg end) type))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7088 (cons (list beg) type)))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7089 (error nil))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7090
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7091 (defun c-looking-at-bos (&optional lim)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7092 ;; Return non-nil if between two statements or declarations, assuming
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7093 ;; point is not inside a literal or comment.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7094 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7095 ;; Obsolete - `c-at-statement-start-p' or `c-at-expression-start-p'
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7096 ;; are recommended instead.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7097 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7098 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7099 (c-at-statement-start-p))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7100 (make-obsolete 'c-looking-at-bos 'c-at-statement-start-p)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7101
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7102 (defun c-looking-at-inexpr-block (lim containing-sexp &optional check-at-end)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7103 ;; Return non-nil if we're looking at the beginning of a block
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7104 ;; inside an expression. The value returned is actually a cons of
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7105 ;; either 'inlambda, 'inexpr-statement or 'inexpr-class and the
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7106 ;; position of the beginning of the construct.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7107 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7108 ;; LIM limits the backward search. CONTAINING-SEXP is the start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7109 ;; position of the closest containing list. If it's nil, the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7110 ;; containing paren isn't used to decide whether we're inside an
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7111 ;; expression or not. If both LIM and CONTAINING-SEXP are used, LIM
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7112 ;; needs to be farther back.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7113 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7114 ;; If CHECK-AT-END is non-nil then extra checks at the end of the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7115 ;; brace block might be done. It should only be used when the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7116 ;; construct can be assumed to be complete, i.e. when the original
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7117 ;; starting position was further down than that.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7118 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7119 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7120
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7121 (save-excursion
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7122 (let ((res 'maybe) passed-paren
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7123 (closest-lim (or containing-sexp lim (point-min)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7124 ;; Look at the character after point only as a last resort
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7125 ;; when we can't disambiguate.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7126 (block-follows (and (eq (char-after) ?{) (point))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7127
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7128 (while (and (eq res 'maybe)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7129 (progn (c-backward-syntactic-ws)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7130 (> (point) closest-lim))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7131 (not (bobp))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7132 (progn (backward-char)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7133 (looking-at "[\]\).]\\|\\w\\|\\s_"))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7134 (c-safe (forward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7135 (goto-char (scan-sexps (point) -1))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7136
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7137 (setq res
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7138 (if (looking-at c-keywords-regexp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7139 (let ((kw-sym (c-keyword-sym (match-string 1))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7140 (cond
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7141 ((and block-follows
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7142 (c-keyword-member kw-sym 'c-inexpr-class-kwds))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7143 (and (not (eq passed-paren ?\[))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7144 (or (not (looking-at c-class-key))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7145 ;; If the class definition is at the start of
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7146 ;; a statement, we don't consider it an
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7147 ;; in-expression class.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7148 (let ((prev (point)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7149 (while (and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7150 (= (c-backward-token-2 1 nil closest-lim) 0)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7151 (eq (char-syntax (char-after)) ?w))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7152 (setq prev (point)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7153 (goto-char prev)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7154 (not (c-at-statement-start-p)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7155 ;; Also, in Pike we treat it as an
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7156 ;; in-expression class if it's used in an
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7157 ;; object clone expression.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7158 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7159 (and check-at-end
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7160 (c-major-mode-is 'pike-mode)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7161 (progn (goto-char block-follows)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7162 (zerop (c-forward-token-2 1 t)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7163 (eq (char-after) ?\())))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7164 (cons 'inexpr-class (point))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7165 ((c-keyword-member kw-sym 'c-inexpr-block-kwds)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7166 (when (not passed-paren)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7167 (cons 'inexpr-statement (point))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7168 ((c-keyword-member kw-sym 'c-lambda-kwds)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7169 (when (or (not passed-paren)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7170 (eq passed-paren ?\())
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7171 (cons 'inlambda (point))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7172 ((c-keyword-member kw-sym 'c-block-stmt-kwds)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7173 nil)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7174 (t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7175 'maybe)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7176
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7177 (if (looking-at "\\s(")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7178 (if passed-paren
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7179 (if (and (eq passed-paren ?\[)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7180 (eq (char-after) ?\[))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7181 ;; Accept several square bracket sexps for
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7182 ;; Java array initializations.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7183 'maybe)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7184 (setq passed-paren (char-after))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7185 'maybe)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7186 'maybe))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7187
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7188 (if (eq res 'maybe)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7189 (when (and c-recognize-paren-inexpr-blocks
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7190 block-follows
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7191 containing-sexp
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7192 (eq (char-after containing-sexp) ?\())
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7193 (goto-char containing-sexp)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7194 (if (or (save-excursion
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7195 (c-backward-syntactic-ws lim)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7196 (and (> (point) (or lim (point-min)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7197 (c-on-identifier)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7198 (and c-special-brace-lists
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7199 (c-looking-at-special-brace-list)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7200 nil
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7201 (cons 'inexpr-statement (point))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7202
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7203 res))))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7204
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7205 (defun c-looking-at-inexpr-block-backward (paren-state)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7206 ;; Returns non-nil if we're looking at the end of an in-expression
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7207 ;; block, otherwise the same as `c-looking-at-inexpr-block'.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7208 ;; PAREN-STATE is the paren state relevant at the current position.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7209 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7210 ;; This function might do hidden buffer changes.
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7211 (save-excursion
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7212 ;; We currently only recognize a block.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7213 (let ((here (point))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7214 (elem (car-safe paren-state))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7215 containing-sexp)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7216 (when (and (consp elem)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7217 (progn (goto-char (cdr elem))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7218 (c-forward-syntactic-ws here)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7219 (= (point) here)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7220 (goto-char (car elem))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7221 (if (setq paren-state (cdr paren-state))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7222 (setq containing-sexp (car-safe paren-state)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7223 (c-looking-at-inexpr-block (c-safe-position containing-sexp
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7224 paren-state)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7225 containing-sexp)))))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7226
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7227
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7228 ;; `c-guess-basic-syntax' and the functions that precedes it below
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7229 ;; implements the main decision tree for determining the syntactic
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7230 ;; analysis of the current line of code.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7231
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7232 ;; Dynamically bound to t when `c-guess-basic-syntax' is called during
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7233 ;; auto newline analysis.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7234 (defvar c-auto-newline-analysis nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7235
78656
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7236 (defun c-brace-anchor-point (bracepos)
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7237 ;; BRACEPOS is the position of a brace in a construct like "namespace
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7238 ;; Bar {". Return the anchor point in this construct; this is the
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7239 ;; earliest symbol on the brace's line which isn't earlier than
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7240 ;; "namespace".
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7241 ;;
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7242 ;; Currently (2007-08-17), "like namespace" means "matches
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7243 ;; c-other-block-decl-kwds". It doesn't work with "class" or "struct"
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7244 ;; or anything like that.
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7245 (save-excursion
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7246 (let ((boi (c-point 'boi bracepos)))
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7247 (goto-char bracepos)
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7248 (while (and (> (point) boi)
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7249 (not (looking-at c-other-decl-block-key)))
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7250 (c-backward-token-2))
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7251 (if (> (point) boi) (point) boi))))
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7252
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7253 (defsubst c-add-syntax (symbol &rest args)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7254 ;; A simple function to prepend a new syntax element to
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7255 ;; `c-syntactic-context'. Using `setq' on it is unsafe since it
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7256 ;; should always be dynamically bound but since we read it first
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7257 ;; we'll fail properly anyway if this function is misused.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7258 (setq c-syntactic-context (cons (cons symbol args)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7259 c-syntactic-context)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7260
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7261 (defsubst c-append-syntax (symbol &rest args)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7262 ;; Like `c-add-syntax' but appends to the end of the syntax list.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7263 ;; (Normally not necessary.)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7264 (setq c-syntactic-context (nconc c-syntactic-context
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7265 (list (cons symbol args)))))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7266
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7267 (defun c-add-stmt-syntax (syntax-symbol
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7268 syntax-extra-args
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7269 stop-at-boi-only
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7270 containing-sexp
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7271 paren-state)
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
7272 ;; Add the indicated SYNTAX-SYMBOL to `c-syntactic-context', extending it as
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
7273 ;; needed with further syntax elements of the types `substatement',
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
7274 ;; `inexpr-statement', `arglist-cont-nonempty', `statement-block-intro', and
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
7275 ;; `defun-block-intro'.
79408
a29ca195b71e (c-crosses-statement-barrier-p): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 78656
diff changeset
7276 ;;
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7277 ;; Do the generic processing to anchor the given syntax symbol on
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7278 ;; the preceding statement: Skip over any labels and containing
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7279 ;; statements on the same line, and then search backward until we
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7280 ;; find a statement or block start that begins at boi without a
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7281 ;; label or comment.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7282 ;;
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7283 ;; Point is assumed to be at the prospective anchor point for the
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7284 ;; given SYNTAX-SYMBOL. More syntax entries are added if we need to
78656
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7285 ;; skip past open parens and containing statements. Most of the added
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7286 ;; syntax elements will get the same anchor point - the exception is
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7287 ;; for an anchor in a construct like "namespace"[*] - this is as early
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7288 ;; as possible in the construct but on the same line as the {.
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7289 ;;
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7290 ;; [*] i.e. with a keyword matching c-other-block-decl-kwds.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7291 ;;
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7292 ;; SYNTAX-EXTRA-ARGS are a list of the extra arguments for the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7293 ;; syntax symbol. They are appended after the anchor point.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7294 ;;
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7295 ;; If STOP-AT-BOI-ONLY is nil, we can stop in the middle of the line
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7296 ;; if the current statement starts there.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7297 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7298 ;; Note: It's not a problem if PAREN-STATE "overshoots"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7299 ;; CONTAINING-SEXP, i.e. contains info about parens further down.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7300 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7301 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7302
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7303 (if (= (point) (c-point 'boi))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7304 ;; This is by far the most common case, so let's give it special
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7305 ;; treatment.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7306 (apply 'c-add-syntax syntax-symbol (point) syntax-extra-args)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7307
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7308 (let ((syntax-last c-syntactic-context)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7309 (boi (c-point 'boi))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7310 ;; Set when we're on a label, so that we don't stop there.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7311 ;; FIXME: To be complete we should check if we're on a label
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7312 ;; now at the start.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7313 on-label)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7314
78656
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7315 ;; Use point as the anchor point for "namespace", "extern", etc.
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7316 (apply 'c-add-syntax syntax-symbol
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7317 (if (rassq syntax-symbol c-other-decl-block-key-in-symbols-alist)
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7318 (point) nil)
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7319 syntax-extra-args)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7320
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7321 ;; Loop while we have to back out of containing blocks.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7322 (while
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7323 (and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7324 (catch 'back-up-block
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7325
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7326 ;; Loop while we have to back up statements.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7327 (while (or (/= (point) boi)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7328 on-label
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7329 (looking-at c-comment-start-regexp))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7330
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7331 ;; Skip past any comments that stands between the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7332 ;; statement start and boi.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7333 (let ((savepos (point)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7334 (while (and (/= savepos boi)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7335 (c-backward-single-comment))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7336 (setq savepos (point)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7337 boi (c-point 'boi)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7338 (goto-char savepos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7339
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7340 ;; Skip to the beginning of this statement or backward
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7341 ;; another one.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7342 (let ((old-pos (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7343 (old-boi boi)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7344 (step-type (c-beginning-of-statement-1 containing-sexp)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7345 (setq boi (c-point 'boi)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7346 on-label (eq step-type 'label))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7347
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7348 (cond ((= (point) old-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7349 ;; If we didn't move we're at the start of a block and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7350 ;; have to continue outside it.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7351 (throw 'back-up-block t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7352
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7353 ((and (eq step-type 'up)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7354 (>= (point) old-boi)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7355 (looking-at "else\\>[^_]")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7356 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7357 (goto-char old-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7358 (looking-at "if\\>[^_]")))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7359 ;; Special case to avoid deeper and deeper indentation
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7360 ;; of "else if" clauses.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7361 )
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7362
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7363 ((and (not stop-at-boi-only)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7364 (/= old-pos old-boi)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7365 (memq step-type '(up previous)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7366 ;; If stop-at-boi-only is nil, we shouldn't back up
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7367 ;; over previous or containing statements to try to
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7368 ;; reach boi, so go back to the last position and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7369 ;; exit.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7370 (goto-char old-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7371 (throw 'back-up-block nil))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7372
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7373 (t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7374 (if (and (not stop-at-boi-only)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7375 (memq step-type '(up previous beginning)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7376 ;; If we've moved into another statement then we
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7377 ;; should no longer try to stop in the middle of a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7378 ;; line.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7379 (setq stop-at-boi-only t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7380
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7381 ;; Record this as a substatement if we skipped up one
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7382 ;; level.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7383 (when (eq step-type 'up)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7384 (c-add-syntax 'substatement nil))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7385 )))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7386
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7387 containing-sexp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7388
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7389 ;; Now we have to go out of this block.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7390 (goto-char containing-sexp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7391
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7392 ;; Don't stop in the middle of a special brace list opener
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7393 ;; like "({".
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7394 (when c-special-brace-lists
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7395 (let ((special-list (c-looking-at-special-brace-list)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7396 (when (and special-list
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7397 (< (car (car special-list)) (point)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7398 (setq containing-sexp (car (car special-list)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7399 (goto-char containing-sexp))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7400
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7401 (setq paren-state (c-whack-state-after containing-sexp paren-state)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7402 containing-sexp (c-most-enclosing-brace paren-state)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7403 boi (c-point 'boi))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7404
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7405 ;; Analyze the construct in front of the block we've stepped out
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7406 ;; from and add the right syntactic element for it.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7407 (let ((paren-pos (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7408 (paren-char (char-after))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7409 step-type)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7410
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7411 (if (eq paren-char ?\()
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7412 ;; Stepped out of a parenthesis block, so we're in an
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7413 ;; expression now.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7414 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7415 (when (/= paren-pos boi)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7416 (if (and c-recognize-paren-inexpr-blocks
45512
17fef404cef1 (c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents: 45049
diff changeset
7417 (progn
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7418 (c-backward-syntactic-ws containing-sexp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7419 (or (not (looking-at "\\>"))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7420 (not (c-on-identifier))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7421 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7422 (goto-char (1+ paren-pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7423 (c-forward-syntactic-ws)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7424 (eq (char-after) ?{)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7425 ;; Stepped out of an in-expression statement. This
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7426 ;; syntactic element won't get an anchor pos.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7427 (c-add-syntax 'inexpr-statement)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7428
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7429 ;; A parenthesis normally belongs to an arglist.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7430 (c-add-syntax 'arglist-cont-nonempty nil paren-pos)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7431
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7432 (goto-char (max boi
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7433 (if containing-sexp
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7434 (1+ containing-sexp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7435 (point-min))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7436 (setq step-type 'same
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7437 on-label nil))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7438
78656
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7439 ;; Stepped out of a brace block.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7440 (setq step-type (c-beginning-of-statement-1 containing-sexp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7441 on-label (eq step-type 'label))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7442
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7443 (if (and (eq step-type 'same)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7444 (/= paren-pos (point)))
78656
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7445 (let (inexpr)
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7446 (cond
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7447 ((save-excursion
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7448 (goto-char paren-pos)
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7449 (setq inexpr (c-looking-at-inexpr-block
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7450 (c-safe-position containing-sexp paren-state)
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7451 containing-sexp)))
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7452 (c-add-syntax (if (eq (car inexpr) 'inlambda)
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7453 'defun-block-intro
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7454 'statement-block-intro)
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7455 nil))
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7456 ((looking-at c-other-decl-block-key)
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7457 (c-add-syntax
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7458 (cdr (assoc (match-string 1)
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7459 c-other-decl-block-key-in-symbols-alist))
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7460 (max (c-point 'boi paren-pos) (point))))
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7461 (t (c-add-syntax 'defun-block-intro nil))))
79408
a29ca195b71e (c-crosses-statement-barrier-p): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 78656
diff changeset
7462
78656
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7463 (c-add-syntax 'statement-block-intro nil)))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7464
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7465 (if (= paren-pos boi)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7466 ;; Always done if the open brace was at boi. The
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7467 ;; c-beginning-of-statement-1 call above is necessary
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7468 ;; anyway, to decide the type of block-intro to add.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7469 (goto-char paren-pos)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7470 (setq boi (c-point 'boi)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7471 ))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7472
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7473 ;; Fill in the current point as the anchor for all the symbols
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7474 ;; added above.
78656
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7475 (let ((p c-syntactic-context) q)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7476 (while (not (eq p syntax-last))
78656
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7477 (setq q (cdr (car p))) ; e.g. (nil 28) [from (arglist-cont-nonempty nil 28)]
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7478 (while q
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7479 (unless (car q)
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7480 (setcar q (point)))
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
7481 (setq q (cdr q)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7482 (setq p (cdr p))))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7483 )))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7484
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7485 (defun c-add-class-syntax (symbol
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7486 containing-decl-open
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7487 containing-decl-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7488 containing-decl-kwd
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7489 paren-state)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7490 ;; The inclass and class-close syntactic symbols are added in
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7491 ;; several places and some work is needed to fix everything.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7492 ;; Therefore it's collected here.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7493 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7494 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7495 (goto-char containing-decl-open)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7496 (if (and (eq symbol 'inclass) (= (point) (c-point 'boi)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7497 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7498 (c-add-syntax symbol containing-decl-open)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7499 containing-decl-open)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7500 (goto-char containing-decl-start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7501 ;; Ought to use `c-add-stmt-syntax' instead of backing up to boi
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7502 ;; here, but we have to do like this for compatibility.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7503 (back-to-indentation)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7504 (c-add-syntax symbol (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7505 (if (and (c-keyword-member containing-decl-kwd
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7506 'c-inexpr-class-kwds)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7507 (/= containing-decl-start (c-point 'boi containing-decl-start)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7508 (c-add-syntax 'inexpr-class))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7509 (point)))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7510
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7511 (defun c-guess-continued-construct (indent-point
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7512 char-after-ip
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7513 beg-of-same-or-containing-stmt
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7514 containing-sexp
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7515 paren-state)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7516 ;; This function contains the decision tree reached through both
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7517 ;; cases 18 and 10. It's a continued statement or top level
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7518 ;; construct of some kind.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7519 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7520 ;; This function might do hidden buffer changes.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7521
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7522 (let (special-brace-list)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7523 (goto-char indent-point)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7524 (skip-chars-forward " \t")
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7525
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7526 (cond
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7527 ;; (CASE A removed.)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7528 ;; CASE B: open braces for class or brace-lists
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7529 ((setq special-brace-list
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7530 (or (and c-special-brace-lists
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7531 (c-looking-at-special-brace-list))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7532 (eq char-after-ip ?{)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7533
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7534 (cond
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7535 ;; CASE B.1: class-open
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7536 ((save-excursion
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7537 (and (eq (char-after) ?{)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7538 (c-looking-at-decl-block containing-sexp t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7539 (setq beg-of-same-or-containing-stmt (point))))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7540 (c-add-syntax 'class-open beg-of-same-or-containing-stmt))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7541
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7542 ;; CASE B.2: brace-list-open
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7543 ((or (consp special-brace-list)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7544 (save-excursion
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7545 (goto-char beg-of-same-or-containing-stmt)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7546 (c-syntactic-re-search-forward "=\\([^=]\\|$\\)"
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7547 indent-point t t t)))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7548 ;; The most semantically accurate symbol here is
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7549 ;; brace-list-open, but we normally report it simply as a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7550 ;; statement-cont. The reason is that one normally adjusts
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7551 ;; brace-list-open for brace lists as top-level constructs,
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7552 ;; and brace lists inside statements is a completely different
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7553 ;; context. C.f. case 5A.3.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7554 (c-beginning-of-statement-1 containing-sexp)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7555 (c-add-stmt-syntax (if c-auto-newline-analysis
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7556 ;; Turn off the dwim above when we're
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7557 ;; analyzing the nature of the brace
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7558 ;; for the auto newline feature.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7559 'brace-list-open
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7560 'statement-cont)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7561 nil nil
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7562 containing-sexp paren-state))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7563
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7564 ;; CASE B.3: The body of a function declared inside a normal
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7565 ;; block. Can occur e.g. in Pike and when using gcc
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
7566 ;; extensions, but watch out for macros followed by blocks.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7567 ;; C.f. cases E, 16F and 17G.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7568 ((and (not (c-at-statement-start-p))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7569 (eq (c-beginning-of-statement-1 containing-sexp nil nil t)
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
7570 'same)
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
7571 (save-excursion
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7572 (let ((c-recognize-typeless-decls nil))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7573 ;; Turn off recognition of constructs that lacks a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7574 ;; type in this case, since that's more likely to be
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7575 ;; a macro followed by a block.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7576 (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7577 (c-add-stmt-syntax 'defun-open nil t
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7578 containing-sexp paren-state))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7579
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
7580 ;; CASE B.4: Continued statement with block open. The most
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
7581 ;; accurate analysis is perhaps `statement-cont' together with
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
7582 ;; `block-open' but we play DWIM and use `substatement-open'
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
7583 ;; instead. The rationaly is that this typically is a macro
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
7584 ;; followed by a block which makes it very similar to a
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
7585 ;; statement with a substatement block.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7586 (t
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7587 (c-add-stmt-syntax 'substatement-open nil nil
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
7588 containing-sexp paren-state))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7589 ))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7590
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7591 ;; CASE C: iostream insertion or extraction operator
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7592 ((and (looking-at "\\(<<\\|>>\\)\\([^=]\\|$\\)")
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7593 (save-excursion
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7594 (goto-char beg-of-same-or-containing-stmt)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7595 ;; If there is no preceding streamop in the statement
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7596 ;; then indent this line as a normal statement-cont.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7597 (when (c-syntactic-re-search-forward
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7598 "\\(<<\\|>>\\)\\([^=]\\|$\\)" indent-point 'move t t)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7599 (c-add-syntax 'stream-op (c-point 'boi))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7600 t))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7601
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7602 ;; CASE E: In the "K&R region" of a function declared inside a
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7603 ;; normal block. C.f. case B.3.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7604 ((and (save-excursion
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7605 ;; Check that the next token is a '{'. This works as
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7606 ;; long as no language that allows nested function
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
7607 ;; definitions allows stuff like member init lists, K&R
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
7608 ;; declarations or throws clauses there.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7609 ;;
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7610 ;; Note that we do a forward search for something ahead
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7611 ;; of the indentation line here. That's not good since
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7612 ;; the user might not have typed it yet. Unfortunately
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7613 ;; it's exceedingly tricky to recognize a function
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7614 ;; prototype in a code block without resorting to this.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7615 (c-forward-syntactic-ws)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7616 (eq (char-after) ?{))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7617 (not (c-at-statement-start-p))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7618 (eq (c-beginning-of-statement-1 containing-sexp nil nil t)
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
7619 'same)
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
7620 (save-excursion
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7621 (let ((c-recognize-typeless-decls nil))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7622 ;; Turn off recognition of constructs that lacks a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7623 ;; type in this case, since that's more likely to be
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7624 ;; a macro followed by a block.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7625 (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7626 (c-add-stmt-syntax 'func-decl-cont nil t
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7627 containing-sexp paren-state))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7628
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7629 ;; CASE D: continued statement.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7630 (t
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7631 (c-beginning-of-statement-1 containing-sexp)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7632 (c-add-stmt-syntax 'statement-cont nil nil
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7633 containing-sexp paren-state))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7634 )))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7635
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7636 ;; The next autoload was added by RMS on 2005/8/9 - don't know why (ACM,
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7637 ;; 2005/11/29).
64833
c4d00dfa8594 (c-guess-basic-syntax): Add autoload.
Richard M. Stallman <rms@gnu.org>
parents: 64699
diff changeset
7638 ;;;###autoload
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7639 (defun c-guess-basic-syntax ()
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7640 "Return the syntactic context of the current line."
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7641 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7642 (beginning-of-line)
51829
d508ffa43505 2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51714
diff changeset
7643 (c-save-buffer-state
d508ffa43505 2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51714
diff changeset
7644 ((indent-point (point))
d508ffa43505 2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51714
diff changeset
7645 (case-fold-search nil)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7646 ;; A whole ugly bunch of various temporary variables. Have
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7647 ;; to declare them here since it's not possible to declare
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7648 ;; a variable with only the scope of a cond test and the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7649 ;; following result clauses, and most of this function is a
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7650 ;; single gigantic cond. :P
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7651 literal char-before-ip before-ws-ip char-after-ip macro-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7652 in-macro-expr c-syntactic-context placeholder c-in-literal-cache
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7653 step-type tmpsymbol keyword injava-inher special-brace-list tmp-pos
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7654 ;; The following record some positions for the containing
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7655 ;; declaration block if we're directly within one:
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7656 ;; `containing-decl-open' is the position of the open
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7657 ;; brace. `containing-decl-start' is the start of the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7658 ;; declaration. `containing-decl-kwd' is the keyword
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7659 ;; symbol of the keyword that tells what kind of block it
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7660 ;; is.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7661 containing-decl-open
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7662 containing-decl-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7663 containing-decl-kwd
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7664 ;; The open paren of the closest surrounding sexp or nil if
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7665 ;; there is none.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7666 containing-sexp
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7667 ;; The position after the closest preceding brace sexp
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7668 ;; (nested sexps are ignored), or the position after
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7669 ;; `containing-sexp' if there is none, or (point-min) if
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7670 ;; `containing-sexp' is nil.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7671 lim
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7672 ;; The paren state outside `containing-sexp', or at
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7673 ;; `indent-point' if `containing-sexp' is nil.
51829
d508ffa43505 2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51714
diff changeset
7674 (paren-state (c-parse-state))
d508ffa43505 2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51714
diff changeset
7675 ;; There's always at most one syntactic element which got
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7676 ;; an anchor pos. It's stored in syntactic-relpos.
51829
d508ffa43505 2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51714
diff changeset
7677 syntactic-relpos
d508ffa43505 2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51714
diff changeset
7678 (c-stmt-delim-chars c-stmt-delim-chars))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7679
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7680 ;; Check if we're directly inside an enclosing declaration
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7681 ;; level block.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7682 (when (and (setq containing-sexp
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7683 (c-most-enclosing-brace paren-state))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7684 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7685 (goto-char containing-sexp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7686 (eq (char-after) ?{))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7687 (setq placeholder
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7688 (c-looking-at-decl-block
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7689 (c-most-enclosing-brace paren-state
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7690 containing-sexp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7691 t)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7692 (setq containing-decl-open containing-sexp
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7693 containing-decl-start (point)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7694 containing-sexp nil)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7695 (goto-char placeholder)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7696 (setq containing-decl-kwd (and (looking-at c-keywords-regexp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7697 (c-keyword-sym (match-string 1)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7698
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7699 ;; Init some position variables.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7700 (if c-state-cache
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7701 (progn
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7702 (setq containing-sexp (car paren-state)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7703 paren-state (cdr paren-state))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7704 (if (consp containing-sexp)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7705 (progn
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7706 (setq lim (cdr containing-sexp))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7707 (if (cdr c-state-cache)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7708 ;; Ignore balanced paren. The next entry
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7709 ;; can't be another one.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7710 (setq containing-sexp (car (cdr c-state-cache))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7711 paren-state (cdr paren-state))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7712 ;; If there is no surrounding open paren then
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7713 ;; put the last balanced pair back on paren-state.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7714 (setq paren-state (cons containing-sexp paren-state)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7715 containing-sexp nil)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7716 (setq lim (1+ containing-sexp))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7717 (setq lim (point-min)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7718
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7719 ;; If we're in a parenthesis list then ',' delimits the
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7720 ;; "statements" rather than being an operator (with the
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7721 ;; exception of the "for" clause). This difference is
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7722 ;; typically only noticeable when statements are used in macro
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7723 ;; arglists.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7724 (when (and containing-sexp
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7725 (eq (char-after containing-sexp) ?\())
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7726 (setq c-stmt-delim-chars c-stmt-delim-chars-with-comma))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7727
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7728 ;; cache char before and after indent point, and move point to
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7729 ;; the most likely position to perform the majority of tests
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7730 (goto-char indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7731 (c-backward-syntactic-ws lim)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7732 (setq before-ws-ip (point)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7733 char-before-ip (char-before))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7734 (goto-char indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7735 (skip-chars-forward " \t")
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7736 (setq char-after-ip (char-after))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7737
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7738 ;; are we in a literal?
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7739 (setq literal (c-in-literal lim))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7740
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7741 ;; now figure out syntactic qualities of the current line
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7742 (cond
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7743
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7744 ;; CASE 1: in a string.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7745 ((eq literal 'string)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7746 (c-add-syntax 'string (c-point 'bopl)))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7747
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7748 ;; CASE 2: in a C or C++ style comment.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7749 ((and (memq literal '(c c++))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7750 ;; This is a kludge for XEmacs where we use
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7751 ;; `buffer-syntactic-context', which doesn't correctly
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7752 ;; recognize "\*/" to end a block comment.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7753 ;; `parse-partial-sexp' which is used by
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7754 ;; `c-literal-limits' will however do that in most
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7755 ;; versions, which results in that we get nil from
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7756 ;; `c-literal-limits' even when `c-in-literal' claims
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7757 ;; we're inside a comment.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7758 (setq placeholder (c-literal-limits lim)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7759 (c-add-syntax literal (car placeholder)))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7760
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
7761 ;; CASE 3: in a cpp preprocessor macro continuation.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7762 ((and (save-excursion
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7763 (when (c-beginning-of-macro)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7764 (setq macro-start (point))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7765 (/= macro-start (c-point 'boi))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7766 (progn
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7767 (setq tmpsymbol 'cpp-macro-cont)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7768 (or (not c-syntactic-indentation-in-macros)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7769 (save-excursion
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7770 (goto-char macro-start)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7771 ;; If at the beginning of the body of a #define
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7772 ;; directive then analyze as cpp-define-intro
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7773 ;; only. Go on with the syntactic analysis
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7774 ;; otherwise. in-macro-expr is set if we're in a
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7775 ;; cpp expression, i.e. before the #define body
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7776 ;; or anywhere in a non-#define directive.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7777 (if (c-forward-to-cpp-define-body)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7778 (let ((indent-boi (c-point 'boi indent-point)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7779 (setq in-macro-expr (> (point) indent-boi)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7780 tmpsymbol 'cpp-define-intro)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7781 (= (point) indent-boi))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7782 (setq in-macro-expr t)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7783 nil)))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7784 (c-add-syntax tmpsymbol macro-start)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7785 (setq macro-start nil))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7786
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7787 ;; CASE 11: an else clause?
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7788 ((looking-at "else\\>[^_]")
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7789 (c-beginning-of-statement-1 containing-sexp)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7790 (c-add-stmt-syntax 'else-clause nil t
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7791 containing-sexp paren-state))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7792
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7793 ;; CASE 12: while closure of a do/while construct?
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7794 ((and (looking-at "while\\>[^_]")
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7795 (save-excursion
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7796 (prog1 (eq (c-beginning-of-statement-1 containing-sexp)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7797 'beginning)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7798 (setq placeholder (point)))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7799 (goto-char placeholder)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7800 (c-add-stmt-syntax 'do-while-closure nil t
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7801 containing-sexp paren-state))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7802
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7803 ;; CASE 13: A catch or finally clause? This case is simpler
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7804 ;; than if-else and do-while, because a block is required
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7805 ;; after every try, catch and finally.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7806 ((save-excursion
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7807 (and (cond ((c-major-mode-is 'c++-mode)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7808 (looking-at "catch\\>[^_]"))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7809 ((c-major-mode-is 'java-mode)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7810 (looking-at "\\(catch\\|finally\\)\\>[^_]")))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7811 (and (c-safe (c-backward-syntactic-ws)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7812 (c-backward-sexp)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7813 t)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7814 (eq (char-after) ?{)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7815 (c-safe (c-backward-syntactic-ws)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7816 (c-backward-sexp)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7817 t)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7818 (if (eq (char-after) ?\()
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7819 (c-safe (c-backward-sexp) t)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7820 t))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7821 (looking-at "\\(try\\|catch\\)\\>[^_]")
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7822 (setq placeholder (point))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7823 (goto-char placeholder)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7824 (c-add-stmt-syntax 'catch-clause nil t
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7825 containing-sexp paren-state))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7826
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7827 ;; CASE 18: A substatement we can recognize by keyword.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7828 ((save-excursion
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7829 (and c-opt-block-stmt-key
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7830 (not (eq char-before-ip ?\;))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7831 (not (c-at-vsemi-p before-ws-ip))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7832 (not (memq char-after-ip '(?\) ?\] ?,)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7833 (or (not (eq char-before-ip ?}))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7834 (c-looking-at-inexpr-block-backward c-state-cache))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7835 (> (point)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7836 (progn
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7837 ;; Ought to cache the result from the
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7838 ;; c-beginning-of-statement-1 calls here.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7839 (setq placeholder (point))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7840 (while (eq (setq step-type
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7841 (c-beginning-of-statement-1 lim))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7842 'label))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7843 (if (eq step-type 'previous)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7844 (goto-char placeholder)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7845 (setq placeholder (point))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7846 (if (and (eq step-type 'same)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7847 (not (looking-at c-opt-block-stmt-key)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7848 ;; Step up to the containing statement if we
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7849 ;; stayed in the same one.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7850 (let (step)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7851 (while (eq
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7852 (setq step
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7853 (c-beginning-of-statement-1 lim))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7854 'label))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7855 (if (eq step 'up)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7856 (setq placeholder (point))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7857 ;; There was no containing statement afterall.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7858 (goto-char placeholder)))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7859 placeholder))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7860 (if (looking-at c-block-stmt-2-key)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7861 ;; Require a parenthesis after these keywords.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7862 ;; Necessary to catch e.g. synchronized in Java,
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7863 ;; which can be used both as statement and
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7864 ;; modifier.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7865 (and (zerop (c-forward-token-2 1 nil))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7866 (eq (char-after) ?\())
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7867 (looking-at c-opt-block-stmt-key))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7868
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7869 (if (eq step-type 'up)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7870 ;; CASE 18A: Simple substatement.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7871 (progn
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7872 (goto-char placeholder)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7873 (cond
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7874 ((eq char-after-ip ?{)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7875 (c-add-stmt-syntax 'substatement-open nil nil
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7876 containing-sexp paren-state))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7877 ((save-excursion
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7878 (goto-char indent-point)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7879 (back-to-indentation)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7880 (c-forward-label))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7881 (c-add-stmt-syntax 'substatement-label nil nil
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7882 containing-sexp paren-state))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7883 (t
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7884 (c-add-stmt-syntax 'substatement nil nil
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7885 containing-sexp paren-state))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7886
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7887 ;; CASE 18B: Some other substatement. This is shared
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7888 ;; with case 10.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7889 (c-guess-continued-construct indent-point
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7890 char-after-ip
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7891 placeholder
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7892 lim
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7893 paren-state)))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7894
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7895 ;; CASE 14: A case or default label
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7896 ((looking-at c-label-kwds-regexp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7897 (if containing-sexp
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7898 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7899 (goto-char containing-sexp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7900 (setq lim (c-most-enclosing-brace c-state-cache
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7901 containing-sexp))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7902 (c-backward-to-block-anchor lim)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7903 (c-add-stmt-syntax 'case-label nil t lim paren-state))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7904 ;; Got a bogus label at the top level. In lack of better
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7905 ;; alternatives, anchor it on (point-min).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7906 (c-add-syntax 'case-label (point-min))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7907
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7908 ;; CASE 15: any other label
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7909 ((save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7910 (back-to-indentation)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7911 (and (not (looking-at c-syntactic-ws-start))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7912 (c-forward-label)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7913 (cond (containing-decl-open
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7914 (setq placeholder (c-add-class-syntax 'inclass
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7915 containing-decl-open
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7916 containing-decl-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7917 containing-decl-kwd
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7918 paren-state))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7919 ;; Append access-label with the same anchor point as
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7920 ;; inclass gets.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7921 (c-append-syntax 'access-label placeholder))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7922
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7923 (containing-sexp
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7924 (goto-char containing-sexp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7925 (setq lim (c-most-enclosing-brace c-state-cache
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7926 containing-sexp))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7927 (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7928 (setq tmpsymbol
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7929 (if (and (eq (c-beginning-of-statement-1 lim) 'up)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7930 (looking-at "switch\\>[^_]"))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7931 ;; If the surrounding statement is a switch then
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7932 ;; let's analyze all labels as switch labels, so
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7933 ;; that they get lined up consistently.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7934 'case-label
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7935 'label)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7936 (c-backward-to-block-anchor lim)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7937 (c-add-stmt-syntax tmpsymbol nil t lim paren-state))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7938
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7939 (t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7940 ;; A label on the top level. Treat it as a class
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7941 ;; context. (point-min) is the closest we get to the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7942 ;; class open brace.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7943 (c-add-syntax 'access-label (point-min)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7944
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7945 ;; CASE 4: In-expression statement. C.f. cases 7B, 16A and
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7946 ;; 17E.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7947 ((setq placeholder (c-looking-at-inexpr-block
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7948 (c-safe-position containing-sexp paren-state)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7949 containing-sexp
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7950 ;; Have to turn on the heuristics after
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7951 ;; the point even though it doesn't work
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7952 ;; very well. C.f. test case class-16.pike.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7953 t))
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
7954 (setq tmpsymbol (assq (car placeholder)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
7955 '((inexpr-class . class-open)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
7956 (inexpr-statement . block-open))))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
7957 (if tmpsymbol
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
7958 ;; It's a statement block or an anonymous class.
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
7959 (setq tmpsymbol (cdr tmpsymbol))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
7960 ;; It's a Pike lambda. Check whether we are between the
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
7961 ;; lambda keyword and the argument list or at the defun
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
7962 ;; opener.
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
7963 (setq tmpsymbol (if (eq char-after-ip ?{)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
7964 'inline-open
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
7965 'lambda-intro-cont)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
7966 (goto-char (cdr placeholder))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
7967 (back-to-indentation)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7968 (c-add-stmt-syntax tmpsymbol nil t
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
7969 (c-most-enclosing-brace c-state-cache (point))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7970 paren-state)
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
7971 (unless (eq (point) (cdr placeholder))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
7972 (c-add-syntax (car placeholder))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7973
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7974 ;; CASE 5: Line is inside a declaration level block or at top level.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7975 ((or containing-decl-open (null containing-sexp))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7976 (cond
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7977
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7978 ;; CASE 5A: we are looking at a defun, brace list, class,
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7979 ;; or inline-inclass method opening brace
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7980 ((setq special-brace-list
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7981 (or (and c-special-brace-lists
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7982 (c-looking-at-special-brace-list))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7983 (eq char-after-ip ?{)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7984 (cond
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7985
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
7986 ;; CASE 5A.1: Non-class declaration block open.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
7987 ((save-excursion
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7988 (let (tmp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7989 (and (eq char-after-ip ?{)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7990 (setq tmp (c-looking-at-decl-block containing-sexp t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7991 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7992 (setq placeholder (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7993 (goto-char tmp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7994 (looking-at c-symbol-key))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7995 (c-keyword-member
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7996 (c-keyword-sym (setq keyword (match-string 0)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7997 'c-other-block-decl-kwds))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7998 (goto-char placeholder)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
7999 (c-add-stmt-syntax
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8000 (if (string-equal keyword "extern")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8001 ;; Special case for extern-lang-open.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8002 'extern-lang-open
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8003 (intern (concat keyword "-open")))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8004 nil t containing-sexp paren-state))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8005
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8006 ;; CASE 5A.2: we are looking at a class opening brace
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8007 ((save-excursion
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8008 (goto-char indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8009 (skip-chars-forward " \t")
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8010 (and (eq (char-after) ?{)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8011 (c-looking-at-decl-block containing-sexp t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8012 (setq placeholder (point))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8013 (c-add-syntax 'class-open placeholder))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8014
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8015 ;; CASE 5A.3: brace list open
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8016 ((save-excursion
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8017 (c-beginning-of-decl-1 lim)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8018 (while (looking-at c-specifier-key)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8019 (goto-char (match-end 1))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8020 (c-forward-syntactic-ws indent-point))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8021 (setq placeholder (c-point 'boi))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8022 (or (consp special-brace-list)
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8023 (and (or (save-excursion
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8024 (goto-char indent-point)
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8025 (setq tmpsymbol nil)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8026 (while (and (> (point) placeholder)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8027 (zerop (c-backward-token-2 1 t))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8028 (/= (char-after) ?=))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8029 (and c-opt-inexpr-brace-list-key
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8030 (not tmpsymbol)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8031 (looking-at c-opt-inexpr-brace-list-key)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8032 (setq tmpsymbol 'topmost-intro-cont)))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8033 (eq (char-after) ?=))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8034 (looking-at c-brace-list-key))
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
8035 (save-excursion
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8036 (while (and (< (point) indent-point)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8037 (zerop (c-forward-token-2 1 t))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8038 (not (memq (char-after) '(?\; ?\()))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8039 (not (memq (char-after) '(?\; ?\()))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8040 ))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8041 (if (and (not c-auto-newline-analysis)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8042 (c-major-mode-is 'java-mode)
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8043 (eq tmpsymbol 'topmost-intro-cont))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8044 ;; We're in Java and have found that the open brace
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8045 ;; belongs to a "new Foo[]" initialization list,
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8046 ;; which means the brace list is part of an
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8047 ;; expression and not a top level definition. We
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8048 ;; therefore treat it as any topmost continuation
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8049 ;; even though the semantically correct symbol still
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8050 ;; is brace-list-open, on the same grounds as in
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8051 ;; case B.2.
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8052 (progn
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8053 (c-beginning-of-statement-1 lim)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8054 (c-add-syntax 'topmost-intro-cont (c-point 'boi)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8055 (c-add-syntax 'brace-list-open placeholder)))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8056
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8057 ;; CASE 5A.4: inline defun open
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8058 ((and containing-decl-open
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8059 (not (c-keyword-member containing-decl-kwd
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8060 'c-other-block-decl-kwds)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8061 (c-add-syntax 'inline-open)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8062 (c-add-class-syntax 'inclass
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8063 containing-decl-open
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8064 containing-decl-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8065 containing-decl-kwd
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8066 paren-state))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8067
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8068 ;; CASE 5A.5: ordinary defun open
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8069 (t
79953
6b6540ecfecf (c-guess-basic-syntax, CASE 5A.5): Anchor the "{" of a template function
Alan Mackenzie <acm@muc.de>
parents: 79943
diff changeset
8070 (save-excursion
6b6540ecfecf (c-guess-basic-syntax, CASE 5A.5): Anchor the "{" of a template function
Alan Mackenzie <acm@muc.de>
parents: 79943
diff changeset
8071 (c-beginning-of-decl-1 lim)
6b6540ecfecf (c-guess-basic-syntax, CASE 5A.5): Anchor the "{" of a template function
Alan Mackenzie <acm@muc.de>
parents: 79943
diff changeset
8072 (while (looking-at c-specifier-key)
6b6540ecfecf (c-guess-basic-syntax, CASE 5A.5): Anchor the "{" of a template function
Alan Mackenzie <acm@muc.de>
parents: 79943
diff changeset
8073 (goto-char (match-end 1))
6b6540ecfecf (c-guess-basic-syntax, CASE 5A.5): Anchor the "{" of a template function
Alan Mackenzie <acm@muc.de>
parents: 79943
diff changeset
8074 (c-forward-syntactic-ws indent-point))
6b6540ecfecf (c-guess-basic-syntax, CASE 5A.5): Anchor the "{" of a template function
Alan Mackenzie <acm@muc.de>
parents: 79943
diff changeset
8075 (c-add-syntax 'defun-open (c-point 'boi))
6b6540ecfecf (c-guess-basic-syntax, CASE 5A.5): Anchor the "{" of a template function
Alan Mackenzie <acm@muc.de>
parents: 79943
diff changeset
8076 ;; Bogus to use bol here, but it's the legacy. (Resolved,
6b6540ecfecf (c-guess-basic-syntax, CASE 5A.5): Anchor the "{" of a template function
Alan Mackenzie <acm@muc.de>
parents: 79943
diff changeset
8077 ;; 2007-11-09)
6b6540ecfecf (c-guess-basic-syntax, CASE 5A.5): Anchor the "{" of a template function
Alan Mackenzie <acm@muc.de>
parents: 79943
diff changeset
8078 ))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8079
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8080 ;; CASE 5B: After a function header but before the body (or
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8081 ;; the ending semicolon if there's no body).
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8082 ((save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8083 (when (setq placeholder (c-just-after-func-arglist-p lim))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8084 (setq tmp-pos (point))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8085 (cond
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8086
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8087 ;; CASE 5B.1: Member init list.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8088 ((eq (char-after tmp-pos) ?:)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8089 (if (or (> tmp-pos indent-point)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8090 (= (c-point 'bosws) (1+ tmp-pos)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8091 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8092 ;; There is no preceding member init clause.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8093 ;; Indent relative to the beginning of indentation
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8094 ;; for the topmost-intro line that contains the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8095 ;; prototype's open paren.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8096 (goto-char placeholder)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8097 (c-add-syntax 'member-init-intro (c-point 'boi)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8098 ;; Indent relative to the first member init clause.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8099 (goto-char (1+ tmp-pos))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8100 (c-forward-syntactic-ws)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8101 (c-add-syntax 'member-init-cont (point))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8102
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8103 ;; CASE 5B.2: K&R arg decl intro
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
8104 ((and c-recognize-knr-p
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
8105 (c-in-knr-argdecl lim))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8106 (c-beginning-of-statement-1 lim)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8107 (c-add-syntax 'knr-argdecl-intro (c-point 'boi))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8108 (if containing-decl-open
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8109 (c-add-class-syntax 'inclass
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8110 containing-decl-open
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8111 containing-decl-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8112 containing-decl-kwd
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8113 paren-state)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8114
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
8115 ;; CASE 5B.4: Nether region after a C++ or Java func
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8116 ;; decl, which could include a `throws' declaration.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8117 (t
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8118 (c-beginning-of-statement-1 lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8119 (c-add-syntax 'func-decl-cont (c-point 'boi))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8120 )))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8121
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8122 ;; CASE 5C: inheritance line. could be first inheritance
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8123 ;; line, or continuation of a multiple inheritance
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8124 ((or (and (c-major-mode-is 'c++-mode)
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
8125 (progn
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
8126 (when (eq char-after-ip ?,)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
8127 (skip-chars-forward " \t")
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
8128 (forward-char))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8129 (looking-at c-opt-postfix-decl-spec-key)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8130 (and (or (eq char-before-ip ?:)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8131 ;; watch out for scope operator
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8132 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8133 (and (eq char-after-ip ?:)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8134 (c-safe (forward-char 1) t)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8135 (not (eq (char-after) ?:))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8136 )))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8137 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8138 (c-backward-syntactic-ws lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8139 (if (eq char-before-ip ?:)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8140 (progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8141 (forward-char -1)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8142 (c-backward-syntactic-ws lim)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8143 (back-to-indentation)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8144 (looking-at c-class-key)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8145 ;; for Java
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8146 (and (c-major-mode-is 'java-mode)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8147 (let ((fence (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8148 (c-beginning-of-statement-1 lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8149 (point)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8150 cont done)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8151 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8152 (while (not done)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8153 (cond ((looking-at c-opt-postfix-decl-spec-key)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8154 (setq injava-inher (cons cont (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8155 done t))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8156 ((or (not (c-safe (c-forward-sexp -1) t))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8157 (<= (point) fence))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8158 (setq done t))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8159 )
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8160 (setq cont t)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8161 injava-inher)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8162 (not (c-crosses-statement-barrier-p (cdr injava-inher)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8163 (point)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8164 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8165 (cond
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8166
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8167 ;; CASE 5C.1: non-hanging colon on an inher intro
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8168 ((eq char-after-ip ?:)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8169 (c-beginning-of-statement-1 lim)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8170 (c-add-syntax 'inher-intro (c-point 'boi))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8171 ;; don't add inclass symbol since relative point already
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8172 ;; contains any class offset
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8173 )
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8174
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8175 ;; CASE 5C.2: hanging colon on an inher intro
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8176 ((eq char-before-ip ?:)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8177 (c-beginning-of-statement-1 lim)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8178 (c-add-syntax 'inher-intro (c-point 'boi))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8179 (if containing-decl-open
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8180 (c-add-class-syntax 'inclass
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8181 containing-decl-open
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8182 containing-decl-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8183 containing-decl-kwd
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8184 paren-state)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8185
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8186 ;; CASE 5C.3: in a Java implements/extends
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8187 (injava-inher
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8188 (let ((where (cdr injava-inher))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8189 (cont (car injava-inher)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8190 (goto-char where)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8191 (cond ((looking-at "throws\\>[^_]")
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8192 (c-add-syntax 'func-decl-cont
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8193 (progn (c-beginning-of-statement-1 lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8194 (c-point 'boi))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8195 (cont (c-add-syntax 'inher-cont where))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8196 (t (c-add-syntax 'inher-intro
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8197 (progn (goto-char (cdr injava-inher))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8198 (c-beginning-of-statement-1 lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8199 (point))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8200 )))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8201
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8202 ;; CASE 5C.4: a continued inheritance line
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8203 (t
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8204 (c-beginning-of-inheritance-list lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8205 (c-add-syntax 'inher-cont (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8206 ;; don't add inclass symbol since relative point already
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8207 ;; contains any class offset
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8208 )))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8209
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8210 ;; CASE 5D: this could be a top-level initialization, a
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
8211 ;; member init list continuation, or a template argument
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
8212 ;; list continuation.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8213 ((save-excursion
98693
69a04789c5f0 Amend several doc strings and comments.
Alan Mackenzie <acm@muc.de>
parents: 96145
diff changeset
8214 ;; Note: We use the fact that lim is always after any
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8215 ;; preceding brace sexp.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8216 (if c-recognize-<>-arglists
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8217 (while (and
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8218 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8219 (c-syntactic-skip-backward "^;,=<>" lim t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8220 (> (point) lim))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8221 (or
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8222 (when c-overloadable-operators-regexp
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8223 (when (setq placeholder (c-after-special-operator-id lim))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8224 (goto-char placeholder)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8225 t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8226 (cond
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8227 ((eq (char-before) ?>)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8228 (or (c-backward-<>-arglist nil lim)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8229 (backward-char))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8230 t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8231 ((eq (char-before) ?<)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8232 (backward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8233 (if (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8234 (c-forward-<>-arglist nil))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8235 (progn (forward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8236 nil)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8237 t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8238 (t nil)))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8239 ;; NB: No c-after-special-operator-id stuff in this
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8240 ;; clause - we assume only C++ needs it.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8241 (c-syntactic-skip-backward "^;,=" lim t))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8242 (memq (char-before) '(?, ?= ?<)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8243 (cond
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8244
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8245 ;; CASE 5D.3: perhaps a template list continuation?
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8246 ((and (c-major-mode-is 'c++-mode)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8247 (save-excursion
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8248 (save-restriction
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8249 (c-with-syntax-table c++-template-syntax-table
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8250 (goto-char indent-point)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8251 (setq placeholder (c-up-list-backward))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8252 (and placeholder
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8253 (eq (char-after placeholder) ?<))))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8254 (c-with-syntax-table c++-template-syntax-table
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8255 (goto-char placeholder)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8256 (c-beginning-of-statement-1 lim t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8257 (if (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8258 (c-backward-syntactic-ws lim)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8259 (eq (char-before) ?<))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8260 ;; In a nested template arglist.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8261 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8262 (goto-char placeholder)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8263 (c-syntactic-skip-backward "^,;" lim t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8264 (c-forward-syntactic-ws))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8265 (back-to-indentation)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8266 ;; FIXME: Should use c-add-stmt-syntax, but it's not yet
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8267 ;; template aware.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8268 (c-add-syntax 'template-args-cont (point)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8269
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8270 ;; CASE 5D.4: perhaps a multiple inheritance line?
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8271 ((and (c-major-mode-is 'c++-mode)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8272 (save-excursion
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8273 (c-beginning-of-statement-1 lim)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8274 (setq placeholder (point))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8275 (if (looking-at "static\\>[^_]")
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8276 (c-forward-token-2 1 nil indent-point))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8277 (and (looking-at c-class-key)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8278 (zerop (c-forward-token-2 2 nil indent-point))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8279 (if (eq (char-after) ?<)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8280 (c-with-syntax-table c++-template-syntax-table
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8281 (zerop (c-forward-token-2 1 t indent-point)))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8282 t)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8283 (eq (char-after) ?:))))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8284 (goto-char placeholder)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8285 (c-add-syntax 'inher-cont (c-point 'boi)))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8286
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8287 ;; CASE 5D.5: Continuation of the "expression part" of a
96145
598aca8e5d9d (c-guess-basic-syntax CASE 5D.5): Fix an infinite loop on invalid syntax.
Alan Mackenzie <acm@muc.de>
parents: 94673
diff changeset
8288 ;; top level construct. Or, perhaps, an unrecognised construct.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8289 (t
96145
598aca8e5d9d (c-guess-basic-syntax CASE 5D.5): Fix an infinite loop on invalid syntax.
Alan Mackenzie <acm@muc.de>
parents: 94673
diff changeset
8290 (while (and (setq placeholder (point))
598aca8e5d9d (c-guess-basic-syntax CASE 5D.5): Fix an infinite loop on invalid syntax.
Alan Mackenzie <acm@muc.de>
parents: 94673
diff changeset
8291 (eq (car (c-beginning-of-decl-1 containing-sexp))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8292 'same)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8293 (save-excursion
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8294 (c-backward-syntactic-ws)
96145
598aca8e5d9d (c-guess-basic-syntax CASE 5D.5): Fix an infinite loop on invalid syntax.
Alan Mackenzie <acm@muc.de>
parents: 94673
diff changeset
8295 (eq (char-before) ?}))
598aca8e5d9d (c-guess-basic-syntax CASE 5D.5): Fix an infinite loop on invalid syntax.
Alan Mackenzie <acm@muc.de>
parents: 94673
diff changeset
8296 (< (point) placeholder)))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8297 (c-add-stmt-syntax
96145
598aca8e5d9d (c-guess-basic-syntax CASE 5D.5): Fix an infinite loop on invalid syntax.
Alan Mackenzie <acm@muc.de>
parents: 94673
diff changeset
8298 (cond
598aca8e5d9d (c-guess-basic-syntax CASE 5D.5): Fix an infinite loop on invalid syntax.
Alan Mackenzie <acm@muc.de>
parents: 94673
diff changeset
8299 ((eq (point) placeholder) 'statement) ; unrecognised construct
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8300 ;; A preceding comma at the top level means that a
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8301 ;; new variable declaration starts here. Use
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8302 ;; topmost-intro-cont for it, for consistency with
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8303 ;; the first variable declaration. C.f. case 5N.
96145
598aca8e5d9d (c-guess-basic-syntax CASE 5D.5): Fix an infinite loop on invalid syntax.
Alan Mackenzie <acm@muc.de>
parents: 94673
diff changeset
8304 ((eq char-before-ip ?,) 'topmost-intro-cont)
598aca8e5d9d (c-guess-basic-syntax CASE 5D.5): Fix an infinite loop on invalid syntax.
Alan Mackenzie <acm@muc.de>
parents: 94673
diff changeset
8305 (t 'statement-cont))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8306 nil nil containing-sexp paren-state))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8307 ))
79408
a29ca195b71e (c-crosses-statement-barrier-p): Fix typo in docstring.
Juanma Barranquero <lekktu@gmail.com>
parents: 78656
diff changeset
8308
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8309 ;; CASE 5F: Close of a non-class declaration level block.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8310 ((and (eq char-after-ip ?})
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8311 (c-keyword-member containing-decl-kwd
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8312 'c-other-block-decl-kwds))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8313 ;; This is inconsistent: Should use `containing-decl-open'
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8314 ;; here if it's at boi, like in case 5J.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8315 (goto-char containing-decl-start)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8316 (c-add-stmt-syntax
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8317 (if (string-equal (symbol-name containing-decl-kwd) "extern")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8318 ;; Special case for compatibility with the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8319 ;; extern-lang syntactic symbols.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8320 'extern-lang-close
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8321 (intern (concat (symbol-name containing-decl-kwd)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8322 "-close")))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8323 nil t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8324 (c-most-enclosing-brace paren-state (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8325 paren-state))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8326
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8327 ;; CASE 5G: we are looking at the brace which closes the
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8328 ;; enclosing nested class decl
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8329 ((and containing-sexp
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8330 (eq char-after-ip ?})
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8331 (eq containing-decl-open containing-sexp))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8332 (c-add-class-syntax 'class-close
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8333 containing-decl-open
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8334 containing-decl-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8335 containing-decl-kwd
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8336 paren-state))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8337
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8338 ;; CASE 5H: we could be looking at subsequent knr-argdecls
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8339 ((and c-recognize-knr-p
79838
2ec37d0d0d39 (c-guess-basic-syntax): prevent a macro call inside a struct being
Alan Mackenzie <acm@muc.de>
parents: 79717
diff changeset
8340 (not containing-sexp) ; can't be knr inside braces.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8341 (not (eq char-before-ip ?}))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8342 (save-excursion
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8343 (setq placeholder (cdr (c-beginning-of-decl-1 lim)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8344 (and placeholder
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8345 ;; Do an extra check to avoid tripping up on
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8346 ;; statements that occur in invalid contexts
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8347 ;; (e.g. in macro bodies where we don't really
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8348 ;; know the context of what we're looking at).
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8349 (not (and c-opt-block-stmt-key
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8350 (looking-at c-opt-block-stmt-key)))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8351 (< placeholder indent-point))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8352 (goto-char placeholder)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8353 (c-add-syntax 'knr-argdecl (point)))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8354
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
8355 ;; CASE 5I: ObjC method definition.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8356 ((and c-opt-method-key
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8357 (looking-at c-opt-method-key))
62641
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 62317
diff changeset
8358 (c-beginning-of-statement-1 nil t)
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 62317
diff changeset
8359 (if (= (point) indent-point)
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 62317
diff changeset
8360 ;; Handle the case when it's the first (non-comment)
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 62317
diff changeset
8361 ;; thing in the buffer. Can't look for a 'same return
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 62317
diff changeset
8362 ;; value from cbos1 since ObjC directives currently
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 62317
diff changeset
8363 ;; aren't recognized fully, so that we get 'same
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 62317
diff changeset
8364 ;; instead of 'previous if it moved over a preceding
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 62317
diff changeset
8365 ;; directive.
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 62317
diff changeset
8366 (goto-char (point-min)))
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
8367 (c-add-syntax 'objc-method-intro (c-point 'boi)))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8368
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8369 ;; CASE 5P: AWK pattern or function or continuation
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8370 ;; thereof.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8371 ((c-major-mode-is 'awk-mode)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8372 (setq placeholder (point))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8373 (c-add-stmt-syntax
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8374 (if (and (eq (c-beginning-of-statement-1) 'same)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8375 (/= (point) placeholder))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8376 'topmost-intro-cont
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8377 'topmost-intro)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8378 nil nil
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8379 containing-sexp paren-state))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8380
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8381 ;; CASE 5N: At a variable declaration that follows a class
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8382 ;; definition or some other block declaration that doesn't
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8383 ;; end at the closing '}'. C.f. case 5D.5.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8384 ((progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8385 (c-backward-syntactic-ws lim)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8386 (and (eq (char-before) ?})
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8387 (save-excursion
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8388 (let ((start (point)))
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8389 (if (and c-state-cache
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8390 (consp (car c-state-cache))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8391 (eq (cdar c-state-cache) (point)))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8392 ;; Speed up the backward search a bit.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8393 (goto-char (caar c-state-cache)))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8394 (c-beginning-of-decl-1 containing-sexp)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8395 (setq placeholder (point))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8396 (if (= start (point))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8397 ;; The '}' is unbalanced.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8398 nil
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8399 (c-end-of-decl-1)
52107
3a5379a0d7f3 2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 51947
diff changeset
8400 (>= (point) indent-point))))))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8401 (goto-char placeholder)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8402 (c-add-stmt-syntax 'topmost-intro-cont nil nil
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8403 containing-sexp paren-state))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8404
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8405 ;; NOTE: The point is at the end of the previous token here.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8406
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8407 ;; CASE 5J: we are at the topmost level, make
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8408 ;; sure we skip back past any access specifiers
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8409 ((and
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8410 ;; A macro continuation line is never at top level.
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8411 (not (and macro-start
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8412 (> indent-point macro-start)))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8413 (save-excursion
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8414 (setq placeholder (point))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8415 (or (memq char-before-ip '(?\; ?{ ?} nil))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8416 (c-at-vsemi-p before-ws-ip)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8417 (when (and (eq char-before-ip ?:)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8418 (eq (c-beginning-of-statement-1 lim)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8419 'label))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8420 (c-backward-syntactic-ws lim)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8421 (setq placeholder (point)))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8422 (and (c-major-mode-is 'objc-mode)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8423 (catch 'not-in-directive
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8424 (c-beginning-of-statement-1 lim)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8425 (setq placeholder (point))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8426 (while (and (c-forward-objc-directive)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8427 (< (point) indent-point))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8428 (c-forward-syntactic-ws)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8429 (if (>= (point) indent-point)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8430 (throw 'not-in-directive t))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8431 (setq placeholder (point)))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8432 nil)))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8433 ;; For historic reasons we anchor at bol of the last
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8434 ;; line of the previous declaration. That's clearly
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8435 ;; highly bogus and useless, and it makes our lives hard
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8436 ;; to remain compatible. :P
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8437 (goto-char placeholder)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8438 (c-add-syntax 'topmost-intro (c-point 'bol))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8439 (if containing-decl-open
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8440 (if (c-keyword-member containing-decl-kwd
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8441 'c-other-block-decl-kwds)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8442 (progn
78656
b3cad8795b91 (c-brace-anchor-point): new function. (c-add-stmt-syntax): Give accurate
Alan Mackenzie <acm@muc.de>
parents: 78487
diff changeset
8443 (goto-char (c-brace-anchor-point containing-decl-open))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8444 (c-add-stmt-syntax
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8445 (if (string-equal (symbol-name containing-decl-kwd)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8446 "extern")
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8447 ;; Special case for compatibility with the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8448 ;; extern-lang syntactic symbols.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8449 'inextern-lang
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8450 (intern (concat "in"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8451 (symbol-name containing-decl-kwd))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8452 nil t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8453 (c-most-enclosing-brace paren-state (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8454 paren-state))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8455 (c-add-class-syntax 'inclass
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8456 containing-decl-open
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8457 containing-decl-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8458 containing-decl-kwd
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8459 paren-state)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8460 (when (and c-syntactic-indentation-in-macros
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8461 macro-start
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8462 (/= macro-start (c-point 'boi indent-point)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8463 (c-add-syntax 'cpp-define-intro)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8464 (setq macro-start nil)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8465
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8466 ;; CASE 5K: we are at an ObjC method definition
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8467 ;; continuation line.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8468 ((and c-opt-method-key
62641
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 62317
diff changeset
8469 (save-excursion
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8470 (c-beginning-of-statement-1 lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8471 (beginning-of-line)
62641
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 62317
diff changeset
8472 (when (looking-at c-opt-method-key)
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 62317
diff changeset
8473 (setq placeholder (point)))))
27b53b1903b6 2005-05-23 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents: 62317
diff changeset
8474 (c-add-syntax 'objc-method-args-cont placeholder))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8475
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
8476 ;; CASE 5L: we are at the first argument of a template
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
8477 ;; arglist that begins on the previous line.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8478 ((and c-recognize-<>-arglists
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8479 (eq (char-before) ?<)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8480 (not (and c-overloadable-operators-regexp
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8481 (c-after-special-operator-id lim))))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8482 (c-beginning-of-statement-1 (c-safe-position (point) paren-state))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
8483 (c-add-syntax 'template-args-cont (c-point 'boi)))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8484
75027
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8485 ;; CASE 5Q: we are at a statement within a macro.
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8486 (macro-start
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8487 (c-beginning-of-statement-1 containing-sexp)
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8488 (c-add-stmt-syntax 'statement nil t containing-sexp paren-state))
9f636bd65206 Update CC Mode to version 5.31.4. The detailed changes are those
Alan Mackenzie <acm@muc.de>
parents: 74372
diff changeset
8489
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
8490 ;; CASE 5M: we are at a topmost continuation line
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8491 (t
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8492 (c-beginning-of-statement-1 (c-safe-position (point) paren-state))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8493 (when (c-major-mode-is 'objc-mode)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8494 (setq placeholder (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8495 (while (and (c-forward-objc-directive)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8496 (< (point) indent-point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8497 (c-forward-syntactic-ws)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8498 (setq placeholder (point)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8499 (goto-char placeholder))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8500 (c-add-syntax 'topmost-intro-cont (c-point 'boi)))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8501 ))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8502
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
8503 ;; (CASE 6 has been removed.)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8504
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8505 ;; CASE 7: line is an expression, not a statement. Most
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8506 ;; likely we are either in a function prototype or a function
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8507 ;; call argument list
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8508 ((not (or (and c-special-brace-lists
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8509 (save-excursion
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8510 (goto-char containing-sexp)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8511 (c-looking-at-special-brace-list)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8512 (eq (char-after containing-sexp) ?{)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8513 (cond
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8514
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8515 ;; CASE 7A: we are looking at the arglist closing paren.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8516 ;; C.f. case 7F.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8517 ((memq char-after-ip '(?\) ?\]))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8518 (goto-char containing-sexp)
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
8519 (setq placeholder (c-point 'boi))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8520 (if (and (c-safe (backward-up-list 1) t)
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
8521 (>= (point) placeholder))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8522 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8523 (forward-char)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8524 (skip-chars-forward " \t"))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8525 (goto-char placeholder))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8526 (c-add-stmt-syntax 'arglist-close (list containing-sexp) t
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8527 (c-most-enclosing-brace paren-state (point))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8528 paren-state))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8529
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8530 ;; CASE 7B: Looking at the opening brace of an
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8531 ;; in-expression block or brace list. C.f. cases 4, 16A
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8532 ;; and 17E.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8533 ((and (eq char-after-ip ?{)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8534 (progn
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8535 (setq placeholder (c-inside-bracelist-p (point)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8536 paren-state))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8537 (if placeholder
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8538 (setq tmpsymbol '(brace-list-open . inexpr-class))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8539 (setq tmpsymbol '(block-open . inexpr-statement)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8540 placeholder
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8541 (cdr-safe (c-looking-at-inexpr-block
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8542 (c-safe-position containing-sexp
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8543 paren-state)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8544 containing-sexp)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8545 ;; placeholder is nil if it's a block directly in
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8546 ;; a function arglist. That makes us skip out of
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8547 ;; this case.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8548 )))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8549 (goto-char placeholder)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8550 (back-to-indentation)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8551 (c-add-stmt-syntax (car tmpsymbol) nil t
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8552 (c-most-enclosing-brace paren-state (point))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8553 paren-state)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8554 (if (/= (point) placeholder)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8555 (c-add-syntax (cdr tmpsymbol))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8556
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8557 ;; CASE 7C: we are looking at the first argument in an empty
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8558 ;; argument list. Use arglist-close if we're actually
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8559 ;; looking at a close paren or bracket.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8560 ((memq char-before-ip '(?\( ?\[))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8561 (goto-char containing-sexp)
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
8562 (setq placeholder (c-point 'boi))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8563 (if (and (c-safe (backward-up-list 1) t)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8564 (>= (point) placeholder))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8565 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8566 (forward-char)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8567 (skip-chars-forward " \t"))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8568 (goto-char placeholder))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8569 (c-add-stmt-syntax 'arglist-intro (list containing-sexp) t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8570 (c-most-enclosing-brace paren-state (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8571 paren-state))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8572
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8573 ;; CASE 7D: we are inside a conditional test clause. treat
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8574 ;; these things as statements
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8575 ((progn
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
8576 (goto-char containing-sexp)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8577 (and (c-safe (c-forward-sexp -1) t)
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
8578 (looking-at "\\<for\\>[^_]")))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8579 (goto-char (1+ containing-sexp))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8580 (c-forward-syntactic-ws indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8581 (if (eq char-before-ip ?\;)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8582 (c-add-syntax 'statement (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8583 (c-add-syntax 'statement-cont (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8584 ))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8585
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8586 ;; CASE 7E: maybe a continued ObjC method call. This is the
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8587 ;; case when we are inside a [] bracketed exp, and what
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8588 ;; precede the opening bracket is not an identifier.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8589 ((and c-opt-method-key
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8590 (eq (char-after containing-sexp) ?\[)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8591 (progn
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8592 (goto-char (1- containing-sexp))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8593 (c-backward-syntactic-ws (c-point 'bod))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8594 (if (not (looking-at c-symbol-key))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8595 (c-add-syntax 'objc-method-call-cont containing-sexp))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8596 )))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8597
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8598 ;; CASE 7F: we are looking at an arglist continuation line,
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8599 ;; but the preceding argument is on the same line as the
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8600 ;; opening paren. This case includes multi-line
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8601 ;; mathematical paren groupings, but we could be on a
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8602 ;; for-list continuation line. C.f. case 7A.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8603 ((progn
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8604 (goto-char (1+ containing-sexp))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8605 (< (save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8606 (c-forward-syntactic-ws)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8607 (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8608 (c-point 'bonl)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8609 (goto-char containing-sexp)
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
8610 (setq placeholder (c-point 'boi))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8611 (if (and (c-safe (backward-up-list 1) t)
56646
b7446b6f097d Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents: 53073
diff changeset
8612 (>= (point) placeholder))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8613 (progn
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8614 (forward-char)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8615 (skip-chars-forward " \t"))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8616 (goto-char placeholder))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8617 (c-add-stmt-syntax 'arglist-cont-nonempty (list containing-sexp) t
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8618 (c-most-enclosing-brace c-state-cache (point))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8619 paren-state))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8620
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8621 ;; CASE 7G: we are looking at just a normal arglist
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8622 ;; continuation line
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8623 (t (c-forward-syntactic-ws indent-point)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8624 (c-add-syntax 'arglist-cont (c-point 'boi)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8625 ))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8626
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8627 ;; CASE 8: func-local multi-inheritance line
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8628 ((and (c-major-mode-is 'c++-mode)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8629 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8630 (goto-char indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8631 (skip-chars-forward " \t")
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8632 (looking-at c-opt-postfix-decl-spec-key)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8633 (goto-char indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8634 (skip-chars-forward " \t")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8635 (cond
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8636
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8637 ;; CASE 8A: non-hanging colon on an inher intro
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8638 ((eq char-after-ip ?:)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8639 (c-backward-syntactic-ws lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8640 (c-add-syntax 'inher-intro (c-point 'boi)))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8641
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8642 ;; CASE 8B: hanging colon on an inher intro
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8643 ((eq char-before-ip ?:)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8644 (c-add-syntax 'inher-intro (c-point 'boi)))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8645
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8646 ;; CASE 8C: a continued inheritance line
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8647 (t
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8648 (c-beginning-of-inheritance-list lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8649 (c-add-syntax 'inher-cont (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8650 )))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8651
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8652 ;; CASE 9: we are inside a brace-list
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8653 ((and (not (c-major-mode-is 'awk-mode)) ; Maybe this isn't needed (ACM, 2002/3/29)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8654 (setq special-brace-list
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8655 (or (and c-special-brace-lists ;;;; ALWAYS NIL FOR AWK!!
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8656 (save-excursion
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8657 (goto-char containing-sexp)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8658 (c-looking-at-special-brace-list)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8659 (c-inside-bracelist-p containing-sexp paren-state))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8660 (cond
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8661
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8662 ;; CASE 9A: In the middle of a special brace list opener.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8663 ((and (consp special-brace-list)
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
8664 (save-excursion
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
8665 (goto-char containing-sexp)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
8666 (eq (char-after) ?\())
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8667 (eq char-after-ip (car (cdr special-brace-list))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8668 (goto-char (car (car special-brace-list)))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
8669 (skip-chars-backward " \t")
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8670 (if (and (bolp)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8671 (assoc 'statement-cont
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8672 (setq placeholder (c-guess-basic-syntax))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8673 (setq c-syntactic-context placeholder)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8674 (c-beginning-of-statement-1
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8675 (c-safe-position (1- containing-sexp) paren-state))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8676 (c-forward-token-2 0)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8677 (while (looking-at c-specifier-key)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8678 (goto-char (match-end 1))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8679 (c-forward-syntactic-ws))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
8680 (c-add-syntax 'brace-list-open (c-point 'boi))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8681
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8682 ;; CASE 9B: brace-list-close brace
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8683 ((if (consp special-brace-list)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8684 ;; Check special brace list closer.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8685 (progn
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8686 (goto-char (car (car special-brace-list)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8687 (save-excursion
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8688 (goto-char indent-point)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8689 (back-to-indentation)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8690 (or
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8691 ;; We were between the special close char and the `)'.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8692 (and (eq (char-after) ?\))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8693 (eq (1+ (point)) (cdr (car special-brace-list))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8694 ;; We were before the special close char.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8695 (and (eq (char-after) (cdr (cdr special-brace-list)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8696 (zerop (c-forward-token-2))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8697 (eq (1+ (point)) (cdr (car special-brace-list)))))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8698 ;; Normal brace list check.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8699 (and (eq char-after-ip ?})
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8700 (c-safe (goto-char (c-up-list-backward (point))) t)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8701 (= (point) containing-sexp)))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8702 (if (eq (point) (c-point 'boi))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8703 (c-add-syntax 'brace-list-close (point))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8704 (setq lim (c-most-enclosing-brace c-state-cache (point)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8705 (c-beginning-of-statement-1 lim)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8706 (c-add-stmt-syntax 'brace-list-close nil t lim paren-state)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8707
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8708 (t
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8709 ;; Prepare for the rest of the cases below by going to the
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8710 ;; token following the opening brace
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8711 (if (consp special-brace-list)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8712 (progn
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8713 (goto-char (car (car special-brace-list)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8714 (c-forward-token-2 1 nil indent-point))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8715 (goto-char containing-sexp))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8716 (forward-char)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8717 (let ((start (point)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8718 (c-forward-syntactic-ws indent-point)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8719 (goto-char (max start (c-point 'bol))))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8720 (c-skip-ws-forward indent-point)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8721 (cond
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8722
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8723 ;; CASE 9C: we're looking at the first line in a brace-list
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8724 ((= (point) indent-point)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8725 (if (consp special-brace-list)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8726 (goto-char (car (car special-brace-list)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8727 (goto-char containing-sexp))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8728 (if (eq (point) (c-point 'boi))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8729 (c-add-syntax 'brace-list-intro (point))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8730 (setq lim (c-most-enclosing-brace c-state-cache (point)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8731 (c-beginning-of-statement-1 lim)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8732 (c-add-stmt-syntax 'brace-list-intro nil t lim paren-state)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8733
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8734 ;; CASE 9D: this is just a later brace-list-entry or
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8735 ;; brace-entry-open
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8736 (t (if (or (eq char-after-ip ?{)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8737 (and c-special-brace-lists
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8738 (save-excursion
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8739 (goto-char indent-point)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8740 (c-forward-syntactic-ws (c-point 'eol))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8741 (c-looking-at-special-brace-list (point)))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8742 (c-add-syntax 'brace-entry-open (point))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8743 (c-add-syntax 'brace-list-entry (point))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8744 ))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8745 ))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8746
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8747 ;; CASE 10: A continued statement or top level construct.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8748 ((and (not (memq char-before-ip '(?\; ?:)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8749 (not (c-at-vsemi-p before-ws-ip))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8750 (or (not (eq char-before-ip ?}))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8751 (c-looking-at-inexpr-block-backward c-state-cache))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8752 (> (point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8753 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8754 (c-beginning-of-statement-1 containing-sexp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8755 (setq placeholder (point))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8756 (/= placeholder containing-sexp))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8757 ;; This is shared with case 18.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8758 (c-guess-continued-construct indent-point
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8759 char-after-ip
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8760 placeholder
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8761 containing-sexp
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8762 paren-state))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8763
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8764 ;; CASE 16: block close brace, possibly closing the defun or
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8765 ;; the class
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8766 ((eq char-after-ip ?})
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8767 ;; From here on we have the next containing sexp in lim.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8768 (setq lim (c-most-enclosing-brace paren-state))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8769 (goto-char containing-sexp)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8770 (cond
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8771
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8772 ;; CASE 16E: Closing a statement block? This catches
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8773 ;; cases where it's preceded by a statement keyword,
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8774 ;; which works even when used in an "invalid" context,
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8775 ;; e.g. a macro argument.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8776 ((c-after-conditional)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8777 (c-backward-to-block-anchor lim)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8778 (c-add-stmt-syntax 'block-close nil t lim paren-state))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8779
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8780 ;; CASE 16A: closing a lambda defun or an in-expression
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8781 ;; block? C.f. cases 4, 7B and 17E.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8782 ((setq placeholder (c-looking-at-inexpr-block
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8783 (c-safe-position containing-sexp paren-state)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8784 nil))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8785 (setq tmpsymbol (if (eq (car placeholder) 'inlambda)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8786 'inline-close
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8787 'block-close))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8788 (goto-char containing-sexp)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8789 (back-to-indentation)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8790 (if (= containing-sexp (point))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8791 (c-add-syntax tmpsymbol (point))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8792 (goto-char (cdr placeholder))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8793 (back-to-indentation)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8794 (c-add-stmt-syntax tmpsymbol nil t
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8795 (c-most-enclosing-brace paren-state (point))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8796 paren-state)
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8797 (if (/= (point) (cdr placeholder))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
8798 (c-add-syntax (car placeholder)))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8799
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8800 ;; CASE 16B: does this close an inline or a function in
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8801 ;; a non-class declaration level block?
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8802 ((save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8803 (and lim
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8804 (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8805 (goto-char lim)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8806 (c-looking-at-decl-block
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8807 (c-most-enclosing-brace paren-state lim)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8808 nil))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8809 (setq placeholder (point))))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8810 (c-backward-to-decl-anchor lim)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8811 (back-to-indentation)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8812 (if (save-excursion
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8813 (goto-char placeholder)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8814 (looking-at c-other-decl-block-key))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8815 (c-add-syntax 'defun-close (point))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8816 (c-add-syntax 'inline-close (point))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8817
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8818 ;; CASE 16F: Can be a defun-close of a function declared
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8819 ;; in a statement block, e.g. in Pike or when using gcc
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
8820 ;; extensions, but watch out for macros followed by
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
8821 ;; blocks. Let it through to be handled below.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8822 ;; C.f. cases B.3 and 17G.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8823 ((save-excursion
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8824 (and (not (c-at-statement-start-p))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8825 (eq (c-beginning-of-statement-1 lim nil nil t) 'same)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8826 (setq placeholder (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8827 (let ((c-recognize-typeless-decls nil))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8828 ;; Turn off recognition of constructs that
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8829 ;; lacks a type in this case, since that's more
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8830 ;; likely to be a macro followed by a block.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8831 (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil))))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8832 (back-to-indentation)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8833 (if (/= (point) containing-sexp)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8834 (goto-char placeholder))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8835 (c-add-stmt-syntax 'defun-close nil t lim paren-state))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8836
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8837 ;; CASE 16C: If there is an enclosing brace then this is
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8838 ;; a block close since defun closes inside declaration
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8839 ;; level blocks have been handled above.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8840 (lim
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8841 ;; If the block is preceded by a case/switch label on
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8842 ;; the same line, we anchor at the first preceding label
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8843 ;; at boi. The default handling in c-add-stmt-syntax
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8844 ;; really fixes it better, but we do like this to keep
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8845 ;; the indentation compatible with version 5.28 and
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8846 ;; earlier. C.f. case 17H.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8847 (while (and (/= (setq placeholder (point)) (c-point 'boi))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8848 (eq (c-beginning-of-statement-1 lim) 'label)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8849 (goto-char placeholder)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8850 (if (looking-at c-label-kwds-regexp)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8851 (c-add-syntax 'block-close (point))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8852 (goto-char containing-sexp)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8853 ;; c-backward-to-block-anchor not necessary here; those
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8854 ;; situations are handled in case 16E above.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8855 (c-add-stmt-syntax 'block-close nil t lim paren-state)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8856
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8857 ;; CASE 16D: Only top level defun close left.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8858 (t
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8859 (goto-char containing-sexp)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8860 (c-backward-to-decl-anchor lim)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8861 (c-add-stmt-syntax 'defun-close nil nil
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8862 (c-most-enclosing-brace paren-state)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8863 paren-state))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8864 ))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8865
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8866 ;; CASE 17: Statement or defun catchall.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8867 (t
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8868 (goto-char indent-point)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8869 ;; Back up statements until we find one that starts at boi.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8870 (while (let* ((prev-point (point))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8871 (last-step-type (c-beginning-of-statement-1
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8872 containing-sexp)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8873 (if (= (point) prev-point)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8874 (progn
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8875 (setq step-type (or step-type last-step-type))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8876 nil)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8877 (setq step-type last-step-type)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8878 (/= (point) (c-point 'boi)))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8879 (cond
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8880
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8881 ;; CASE 17B: continued statement
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8882 ((and (eq step-type 'same)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8883 (/= (point) indent-point))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8884 (c-add-stmt-syntax 'statement-cont nil nil
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8885 containing-sexp paren-state))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8886
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8887 ;; CASE 17A: After a case/default label?
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8888 ((progn
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8889 (while (and (eq step-type 'label)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8890 (not (looking-at c-label-kwds-regexp)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8891 (setq step-type
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8892 (c-beginning-of-statement-1 containing-sexp)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8893 (eq step-type 'label))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8894 (c-add-stmt-syntax (if (eq char-after-ip ?{)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8895 'statement-case-open
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8896 'statement-case-intro)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8897 nil t containing-sexp paren-state))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8898
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8899 ;; CASE 17D: any old statement
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8900 ((progn
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8901 (while (eq step-type 'label)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8902 (setq step-type
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8903 (c-beginning-of-statement-1 containing-sexp)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8904 (eq step-type 'previous))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8905 (c-add-stmt-syntax 'statement nil t
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8906 containing-sexp paren-state)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8907 (if (eq char-after-ip ?{)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8908 (c-add-syntax 'block-open)))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8909
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8910 ;; CASE 17I: Inside a substatement block.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8911 ((progn
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8912 ;; The following tests are all based on containing-sexp.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8913 (goto-char containing-sexp)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8914 ;; From here on we have the next containing sexp in lim.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8915 (setq lim (c-most-enclosing-brace paren-state containing-sexp))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8916 (c-after-conditional))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8917 (c-backward-to-block-anchor lim)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8918 (c-add-stmt-syntax 'statement-block-intro nil t
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8919 lim paren-state)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8920 (if (eq char-after-ip ?{)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8921 (c-add-syntax 'block-open)))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8922
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8923 ;; CASE 17E: first statement in an in-expression block.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8924 ;; C.f. cases 4, 7B and 16A.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8925 ((setq placeholder (c-looking-at-inexpr-block
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8926 (c-safe-position containing-sexp paren-state)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8927 nil))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8928 (setq tmpsymbol (if (eq (car placeholder) 'inlambda)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8929 'defun-block-intro
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8930 'statement-block-intro))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8931 (back-to-indentation)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8932 (if (= containing-sexp (point))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8933 (c-add-syntax tmpsymbol (point))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8934 (goto-char (cdr placeholder))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8935 (back-to-indentation)
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8936 (c-add-stmt-syntax tmpsymbol nil t
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8937 (c-most-enclosing-brace c-state-cache (point))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8938 paren-state)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8939 (if (/= (point) (cdr placeholder))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8940 (c-add-syntax (car placeholder))))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8941 (if (eq char-after-ip ?{)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8942 (c-add-syntax 'block-open)))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8943
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
8944 ;; CASE 17F: first statement in an inline, or first
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8945 ;; statement in a top-level defun. we can tell this is it
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8946 ;; if there are no enclosing braces that haven't been
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8947 ;; narrowed out by a class (i.e. don't use bod here).
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8948 ((save-excursion
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8949 (or (not (setq placeholder (c-most-enclosing-brace
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8950 paren-state)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8951 (and (progn
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8952 (goto-char placeholder)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8953 (eq (char-after) ?{))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8954 (c-looking-at-decl-block (c-most-enclosing-brace
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8955 paren-state (point))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8956 nil))))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8957 (c-backward-to-decl-anchor lim)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8958 (back-to-indentation)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8959 (c-add-syntax 'defun-block-intro (point)))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8960
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
8961 ;; CASE 17G: First statement in a function declared inside
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8962 ;; a normal block. This can occur in Pike and with
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
8963 ;; e.g. the gcc extensions, but watch out for macros
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
8964 ;; followed by blocks. C.f. cases B.3 and 16F.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8965 ((save-excursion
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8966 (and (not (c-at-statement-start-p))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8967 (eq (c-beginning-of-statement-1 lim nil nil t) 'same)
53073
49f65e04ba8e CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents: 52605
diff changeset
8968 (setq placeholder (point))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8969 (let ((c-recognize-typeless-decls nil))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8970 ;; Turn off recognition of constructs that lacks
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8971 ;; a type in this case, since that's more likely
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8972 ;; to be a macro followed by a block.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8973 (c-forward-decl-or-cast-1 (c-point 'bosws) nil nil))))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8974 (back-to-indentation)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8975 (if (/= (point) containing-sexp)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8976 (goto-char placeholder))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8977 (c-add-stmt-syntax 'defun-block-intro nil t
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8978 lim paren-state))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8979
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8980 ;; CASE 17H: First statement in a block.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8981 (t
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8982 ;; If the block is preceded by a case/switch label on the
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8983 ;; same line, we anchor at the first preceding label at
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8984 ;; boi. The default handling in c-add-stmt-syntax is
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8985 ;; really fixes it better, but we do like this to keep the
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8986 ;; indentation compatible with version 5.28 and earlier.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8987 ;; C.f. case 16C.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8988 (while (and (/= (setq placeholder (point)) (c-point 'boi))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8989 (eq (c-beginning-of-statement-1 lim) 'label)))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8990 (goto-char placeholder)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8991 (if (looking-at c-label-kwds-regexp)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8992 (c-add-syntax 'statement-block-intro (point))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8993 (goto-char containing-sexp)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8994 ;; c-backward-to-block-anchor not necessary here; those
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8995 ;; situations are handled in case 17I above.
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
8996 (c-add-stmt-syntax 'statement-block-intro nil t
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
8997 lim paren-state))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8998 (if (eq char-after-ip ?{)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
8999 (c-add-syntax 'block-open)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9000 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9001 )
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9002
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9003 ;; now we need to look at any modifiers
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9004 (goto-char indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9005 (skip-chars-forward " \t")
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9006
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9007 ;; are we looking at a comment only line?
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9008 (when (and (looking-at c-comment-start-regexp)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9009 (/= (c-forward-token-2 0 nil (c-point 'eol)) 0))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9010 (c-append-syntax 'comment-intro))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9011
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9012 ;; we might want to give additional offset to friends (in C++).
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9013 (when (and c-opt-friend-key
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9014 (looking-at c-opt-friend-key))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9015 (c-append-syntax 'friend))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9016
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9017 ;; Set syntactic-relpos.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9018 (let ((p c-syntactic-context))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9019 (while (and p
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9020 (if (integerp (c-langelem-pos (car p)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9021 (progn
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9022 (setq syntactic-relpos (c-langelem-pos (car p)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9023 nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9024 t))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9025 (setq p (cdr p))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9026
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9027 ;; Start of or a continuation of a preprocessor directive?
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9028 (if (and macro-start
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9029 (eq macro-start (c-point 'boi))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9030 (not (and (c-major-mode-is 'pike-mode)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9031 (eq (char-after (1+ macro-start)) ?\"))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9032 (c-append-syntax 'cpp-macro)
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9033 (when (and c-syntactic-indentation-in-macros macro-start)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9034 (if in-macro-expr
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9035 (when (or
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9036 (< syntactic-relpos macro-start)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9037 (not (or
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9038 (assq 'arglist-intro c-syntactic-context)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9039 (assq 'arglist-cont c-syntactic-context)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9040 (assq 'arglist-cont-nonempty c-syntactic-context)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9041 (assq 'arglist-close c-syntactic-context))))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9042 ;; If inside a cpp expression, i.e. anywhere in a
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9043 ;; cpp directive except a #define body, we only let
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9044 ;; through the syntactic analysis that is internal
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9045 ;; in the expression. That means the arglist
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9046 ;; elements, if they are anchored inside the cpp
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9047 ;; expression.
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9048 (setq c-syntactic-context nil)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9049 (c-add-syntax 'cpp-macro-cont macro-start))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9050 (when (and (eq macro-start syntactic-relpos)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9051 (not (assq 'cpp-define-intro c-syntactic-context))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9052 (save-excursion
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9053 (goto-char macro-start)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9054 (or (not (c-forward-to-cpp-define-body))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9055 (<= (point) (c-point 'boi indent-point)))))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9056 ;; Inside a #define body and the syntactic analysis is
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9057 ;; anchored on the start of the #define. In this case
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9058 ;; we add cpp-define-intro to get the extra
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9059 ;; indentation of the #define body.
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9060 (c-add-syntax 'cpp-define-intro)))))
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9061
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9062 ;; return the syntax
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9063 c-syntactic-context)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9064
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9065
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9066 ;; Indentation calculation.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9067
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
9068 (defun c-evaluate-offset (offset langelem symbol)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
9069 ;; offset can be a number, a function, a variable, a list, or one of
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
9070 ;; the symbols + or -
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9071 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9072 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9073 (let ((res
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9074 (cond
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9075 ((numberp offset) offset)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9076 ((vectorp offset) offset)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9077 ((null offset) nil)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9078
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9079 ((eq offset '+) c-basic-offset)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9080 ((eq offset '-) (- c-basic-offset))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9081 ((eq offset '++) (* 2 c-basic-offset))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9082 ((eq offset '--) (* 2 (- c-basic-offset)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9083 ((eq offset '*) (/ c-basic-offset 2))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9084 ((eq offset '/) (/ (- c-basic-offset) 2))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9085
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9086 ((functionp offset)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9087 (c-evaluate-offset
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9088 (funcall offset
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9089 (cons (c-langelem-sym langelem)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9090 (c-langelem-pos langelem)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9091 langelem symbol))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9092
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9093 ((listp offset)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9094 (cond
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9095 ((eq (car offset) 'quote)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9096 (c-benign-error "The offset %S for %s was mistakenly quoted"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9097 offset symbol)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9098 nil)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9099
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9100 ((memq (car offset) '(min max))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9101 (let (res val (method (car offset)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9102 (setq offset (cdr offset))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9103 (while offset
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9104 (setq val (c-evaluate-offset (car offset) langelem symbol))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9105 (cond
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9106 ((not val))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9107 ((not res)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9108 (setq res val))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9109 ((integerp val)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9110 (if (vectorp res)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9111 (c-benign-error "\
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9112 Error evaluating offset %S for %s: \
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9113 Cannot combine absolute offset %S with relative %S in `%s' method"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9114 (car offset) symbol res val method)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9115 (setq res (funcall method res val))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9116 (t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9117 (if (integerp res)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9118 (c-benign-error "\
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9119 Error evaluating offset %S for %s: \
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9120 Cannot combine relative offset %S with absolute %S in `%s' method"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9121 (car offset) symbol res val method)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9122 (setq res (vector (funcall method (aref res 0)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9123 (aref val 0)))))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9124 (setq offset (cdr offset)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9125 res))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9126
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9127 ((eq (car offset) 'add)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9128 (let (res val)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9129 (setq offset (cdr offset))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9130 (while offset
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9131 (setq val (c-evaluate-offset (car offset) langelem symbol))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9132 (cond
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9133 ((not val))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9134 ((not res)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9135 (setq res val))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9136 ((integerp val)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9137 (if (vectorp res)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9138 (setq res (vector (+ (aref res 0) val)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9139 (setq res (+ res val))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9140 (t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9141 (if (vectorp res)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9142 (c-benign-error "\
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9143 Error evaluating offset %S for %s: \
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9144 Cannot combine absolute offsets %S and %S in `add' method"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9145 (car offset) symbol res val)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9146 (setq res val)))) ; Override.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9147 (setq offset (cdr offset)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9148 res))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9149
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9150 (t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9151 (let (res)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9152 (when (eq (car offset) 'first)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9153 (setq offset (cdr offset)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9154 (while (and (not res) offset)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9155 (setq res (c-evaluate-offset (car offset) langelem symbol)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9156 offset (cdr offset)))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9157 res))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9158
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9159 ((and (symbolp offset) (boundp offset))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9160 (symbol-value offset))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9161
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9162 (t
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9163 (c-benign-error "Unknown offset format %S for %s" offset symbol)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9164 nil))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9165
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9166 (if (or (null res) (integerp res)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9167 (and (vectorp res) (= (length res) 1) (integerp (aref res 0))))
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9168 res
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9169 (c-benign-error "Error evaluating offset %S for %s: Got invalid value %S"
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9170 offset symbol res)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9171 nil)))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
9172
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9173 (defun c-calc-offset (langelem)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9174 ;; Get offset from LANGELEM which is a list beginning with the
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9175 ;; syntactic symbol and followed by any analysis data it provides.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9176 ;; That data may be zero or more elements, but if at least one is
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9177 ;; given then the first is the anchor position (or nil). The symbol
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9178 ;; is matched against `c-offsets-alist' and the offset calculated
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9179 ;; from that is returned.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9180 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9181 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9182 (let* ((symbol (c-langelem-sym langelem))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
9183 (match (assq symbol c-offsets-alist))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
9184 (offset (cdr-safe match)))
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9185 (if match
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9186 (setq offset (c-evaluate-offset offset langelem symbol))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9187 (if c-strict-syntax-p
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9188 (c-benign-error "No offset found for syntactic symbol %s" symbol))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9189 (setq offset 0))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
9190 (if (vectorp offset)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
9191 offset
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9192 (or (and (numberp offset) offset)
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9193 (and (symbolp offset) (symbol-value offset))
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9194 0))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
9195 ))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
9196
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9197 (defun c-get-offset (langelem)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9198 ;; This is a compatibility wrapper for `c-calc-offset' in case
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9199 ;; someone is calling it directly. It takes an old style syntactic
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9200 ;; element on the form (SYMBOL . ANCHOR-POS) and converts it to the
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9201 ;; new list form.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9202 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9203 ;; This function might do hidden buffer changes.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9204 (if (c-langelem-pos langelem)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9205 (c-calc-offset (list (c-langelem-sym langelem)
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9206 (c-langelem-pos langelem)))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9207 (c-calc-offset langelem)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9208
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
9209 (defun c-get-syntactic-indentation (langelems)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9210 ;; Calculate the syntactic indentation from a syntactic description
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9211 ;; as returned by `c-guess-syntax'.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9212 ;;
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9213 ;; Note that topmost-intro always has an anchor position at bol, for
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9214 ;; historical reasons. It's often used together with other symbols
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9215 ;; that has more sane positions. Since we always use the first
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9216 ;; found anchor position, we rely on that these other symbols always
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9217 ;; precede topmost-intro in the LANGELEMS list.
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9218 ;;
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9219 ;; This function might do hidden buffer changes.
44728
7a3ac6c387fe CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents: 44510
diff changeset
9220 (let ((indent 0) anchor)
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9221
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9222 (while langelems
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9223 (let* ((c-syntactic-element (car langelems))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9224 (res (c-calc-offset c-syntactic-element)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9225
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9226 (if (vectorp res)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9227 ;; Got an absolute column that overrides any indentation
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9228 ;; we've collected so far, but not the relative
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9229 ;; indentation we might get for the nested structures
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9230 ;; further down the langelems list.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9231 (setq indent (elt res 0)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9232 anchor (point-min)) ; A position at column 0.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9233
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9234 ;; Got a relative change of the current calculated
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9235 ;; indentation.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9236 (setq indent (+ indent res))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9237
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9238 ;; Use the anchor position from the first syntactic
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9239 ;; element with one.
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9240 (unless anchor
67252
04d2abb755d9 Update CC Mode to release 5.31.
Alan Mackenzie <acm@muc.de>
parents: 64833
diff changeset
9241 (setq anchor (c-langelem-pos (car langelems)))))
51714
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9242
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9243 (setq langelems (cdr langelems))))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9244
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9245 (if anchor
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9246 (+ indent (save-excursion
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9247 (goto-char anchor)
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9248 (current-column)))
bc91cbf50c24 Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents: 50273
diff changeset
9249 indent)))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
9250
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9251
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
9252 (cc-provide 'cc-engine)
38422
7a94f1c588c4 Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents: 36920
diff changeset
9253
93975
1e3a407766b9 Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents: 92572
diff changeset
9254 ;; arch-tag: 149add18-4673-4da5-ac47-6805e4eae089
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9255 ;;; cc-engine.el ends here