annotate lisp/progmodes/cc-engine.el @ 37122:a34d1e2a580f

Correct syntax table data structure. Other clarifications about syntax tables.
author Richard M. Stallman <rms@gnu.org>
date Sun, 01 Apr 2001 03:25:57 +0000
parents 32a4317c6aa5
children 7a94f1c588c4
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
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
3 ;; Copyright (C) 1985,1987,1992-2001 Free Software Foundation, Inc.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
4
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
5 ;; Authors: 2000- Martin Stjernholm
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
6 ;; 1998-1999 Barry A. Warsaw and Martin Stjernholm
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
7 ;; 1992-1997 Barry A. Warsaw
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; 1987 Dave Detlefs and Stewart Clamen
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9 ;; 1985 Richard M. Stallman
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
10 ;; Maintainer: bug-cc-mode@gnu.org
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; Created: 22-Apr-1997 (split from cc-mode.el)
20142
e66d1eef0bff (c-guess-basic-syntax):
Karl Heuer <kwzh@gnu.org>
parents: 20139
diff changeset
12 ;; Version: See cc-mode.el
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; Keywords: c languages oop
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; This file is part of GNU Emacs.
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 ;; GNU Emacs is free software; you can redistribute it and/or modify
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; it under the terms of the GNU General Public License as published by
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19 ;; the Free Software Foundation; either version 2, or (at your option)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; any later version.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
21
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
22 ;; GNU Emacs is distributed in the hope that it will be useful,
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
23 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
25 ;; GNU General Public License for more details.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
26
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
27 ;; You should have received a copy of the GNU General Public License
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
28 ;; along with this program; see the file COPYING. If not, write to
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
29 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
30 ;; Boston, MA 02111-1307, USA.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
31
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
32 (eval-when-compile
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
33 (let ((load-path
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
34 (if (and (boundp 'byte-compile-dest-file)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
35 (stringp byte-compile-dest-file))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
36 (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
37 load-path)))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
38 (require 'cc-bytecomp)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
39
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
40 (cc-require 'cc-defs)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
41 (cc-require 'cc-vars)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
42 (cc-require 'cc-langs)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
43
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
44 ;; Silence the compiler.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
45 (cc-bytecomp-defun buffer-syntactic-context) ; XEmacs
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
46
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
47
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
48 (defvar c-state-cache nil)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
49 (defvar c-in-literal-cache t)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
50
18844
6b269c4ad2eb (c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 18720
diff changeset
51 ;; 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
52 ;; 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
53 ;; 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
54 ;; the byte compiler.
6b269c4ad2eb (c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 18720
diff changeset
55 (defvar c-maybe-labelp nil)
6b269c4ad2eb (c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 18720
diff changeset
56
6b269c4ad2eb (c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 18720
diff changeset
57 ;; WARNING WARNING WARNING
6b269c4ad2eb (c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 18720
diff changeset
58 ;;
6b269c4ad2eb (c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 18720
diff changeset
59 ;; Be *exceptionally* careful about modifications to this function!
6b269c4ad2eb (c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 18720
diff changeset
60 ;; Much of CC Mode depends on this Doing The Right Thing. If you
6b269c4ad2eb (c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 18720
diff changeset
61 ;; break it you will be sorry. If you think you know how this works,
6b269c4ad2eb (c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 18720
diff changeset
62 ;; you probably don't. No human on Earth does! :-)
6b269c4ad2eb (c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 18720
diff changeset
63 ;;
6b269c4ad2eb (c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 18720
diff changeset
64 ;; WARNING WARNING WARNING
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
65
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
66 (defun c-beginning-of-statement-1 (&optional lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
67 ;; move to the start of the current statement, or the previous
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
68 ;; statement if already at the beginning of one.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
69 (let ((firstp t)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
70 (substmt-p t)
18844
6b269c4ad2eb (c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 18720
diff changeset
71 donep c-in-literal-cache saved
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72 (last-begin (point)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
73 ;; first check for bare semicolon
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
74 (if (and (progn (c-backward-syntactic-ws lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
75 (eq (char-before) ?\;))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
76 (c-safe (progn (forward-char -1)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
77 (setq saved (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
78 t))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
79 (progn (c-backward-syntactic-ws lim)
19251
6a7d40ec4b29 (c-beginning-of-statement-1): When checking for bare semi, don't match
Richard M. Stallman <rms@gnu.org>
parents: 18844
diff changeset
80 (memq (char-before) '(?\; ?{ ?:)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
81 )
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
82 (setq last-begin saved)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
83 (goto-char last-begin)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
84 (while (not donep)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
85 ;; stop at beginning of buffer
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
86 (if (bobp) (setq donep t)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
87 ;; go backwards one balanced expression, but be careful of
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
88 ;; unbalanced paren being reached
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
89 (if (not (c-safe (progn (c-backward-sexp 1) t)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
90 (progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 (if firstp
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
92 (backward-up-list 1)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
93 (goto-char last-begin))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
94 ;; skip over any unary operators, or other special
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95 ;; characters appearing at front of identifier
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
96 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
97 (c-backward-syntactic-ws lim)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
98 (skip-chars-backward "-+!*&:.~@ \t\n")
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
99 (if (eq (char-before) ?\()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
100 (setq last-begin (point))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
101 (goto-char last-begin)
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
102 (setq donep t)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
103
18844
6b269c4ad2eb (c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 18720
diff changeset
104 (setq c-maybe-labelp nil)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
105 ;; see if we're in a literal. if not, then this bufpos may be
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
106 ;; a candidate for stopping
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
107 (cond
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
108 ;; CASE 0: did we hit the error condition above?
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
109 (donep)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 ;; CASE 1: are we in a literal?
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 ((eq (c-in-literal lim) 'pound)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 (beginning-of-line))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 ;; CASE 2: some other kind of literal?
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 ((c-in-literal lim))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115 ;; CASE 3: are we looking at a conditional keyword?
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
116 ((or (and c-conditional-key (looking-at c-conditional-key))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 (and (eq (char-after) ?\()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 (save-excursion
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
119 (c-forward-sexp 1)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 (c-forward-syntactic-ws)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 (not (eq (char-after) ?\;)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122 (let ((here (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
123 (foundp (progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 (c-backward-syntactic-ws lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 (forward-word -1)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 (and lim
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (<= lim (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (not (c-in-literal lim))
20142
e66d1eef0bff (c-guess-basic-syntax):
Karl Heuer <kwzh@gnu.org>
parents: 20139
diff changeset
129 (not (eq (char-before) ?_))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
130 c-conditional-key
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 (looking-at c-conditional-key)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 ))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 ;; did we find a conditional?
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 (if (not foundp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 (goto-char here))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136 foundp)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 ;; are we in the middle of an else-if clause?
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
138 (if (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
139 (and (not substmt-p)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
140 (c-safe (progn (c-forward-sexp -1) t))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
141 (looking-at "\\<else\\>[ \t\n]+\\<if\\>")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
142 (not (c-in-literal lim))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
143 (progn
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
144 (c-forward-sexp -1)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
145 (c-backward-to-start-of-if lim)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
146 ;; are we sitting at an else clause, that we are not a
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
147 ;; substatement of?
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
148 (if (and (not substmt-p)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
149 (looking-at "\\<else\\>[^_]"))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
150 (c-backward-to-start-of-if lim))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
151 ;; a finally or a series of catches?
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
152 (if (not substmt-p)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
153 (while (looking-at "\\<\\(catch\\|finally\\)\\>[^_]")
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
154 (c-safe (c-backward-sexp 2))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
155 (if (eq (char-after) ?\()
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
156 (c-safe (c-backward-sexp)))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
157 ;; are we sitting at the while of a do-while?
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
158 (if (and (looking-at "\\<while\\>[^_]")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
159 (c-backward-to-start-of-do lim))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
160 (setq substmt-p nil))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
161 (setq last-begin (point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
162 donep substmt-p))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
163 ;; CASE 4: are we looking at a label? (But we handle
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
164 ;; switch labels later.)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
165 ((and (looking-at c-label-key)
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
166 (not (looking-at "default\\>"))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
167 (not (and (c-major-mode-is 'pike-mode)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
168 (save-excursion
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
169 ;; Not inside a Pike type declaration?
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
170 (and (c-safe (backward-up-list 1) t)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
171 (eq (char-after) ?\()))))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 ;; CASE 5: is this the first time we're checking?
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 (firstp (setq firstp nil
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
174 substmt-p (not (c-crosses-statement-barrier-p
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
175 (point) last-begin))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
176 last-begin (point)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
177 ;; CASE 6: have we crossed a statement barrier?
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
178 ((save-excursion
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
179 ;; Move over in-expression blocks before checking the
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
180 ;; barrier
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
181 (if (or (memq (char-after) '(?\( ?\[))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
182 (and (eq (char-after) ?{)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
183 (c-looking-at-inexpr-block lim)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
184 (c-forward-sexp 1))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
185 (c-crosses-statement-barrier-p (point) last-begin))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 (setq donep t))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 ;; CASE 7: ignore labels
18844
6b269c4ad2eb (c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 18720
diff changeset
188 ((and c-maybe-labelp
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
189 (or (and c-access-key (looking-at c-access-key))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
190 ;; with switch labels, we have to go back further
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
191 ;; to try to pick up the case or default
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
192 ;; keyword. Potential bogosity alert: we assume
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
193 ;; `case' or `default' is first thing on line
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
194 (let ((here (point)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 (beginning-of-line)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
196 (c-forward-syntactic-ws here)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
197 (if (looking-at c-switch-label-key)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
198 t
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199 (goto-char here)
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
200 nil)))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
201 ;; CASE 8: ObjC or Java method def
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
202 ((and c-method-key
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
203 (setq last-begin (c-in-method-def-p)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
204 (setq donep t))
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
205 ;; CASE 9: Normal token. At bob, we can end up at ws or a
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
206 ;; comment, and last-begin shouldn't be updated then.
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
207 ((not (looking-at "\\s \\|/[/*]"))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
208 (setq last-begin (point)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
209 ))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
210 (goto-char last-begin)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
211 ;; We always want to skip over the non-whitespace modifier
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
212 ;; characters that can start a statement.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
213 (let ((lim (point)))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
214 (skip-chars-backward "-+!*&~@`# \t\n" (c-point 'boi))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
215 (skip-chars-forward " \t\n" lim))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
216
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
217 (defun c-end-of-statement-1 ()
19377
989d0412ada3 (c-end-of-statement-1): Eliminate false hits on important characters
Richard M. Stallman <rms@gnu.org>
parents: 19301
diff changeset
218 (condition-case nil
989d0412ada3 (c-end-of-statement-1): Eliminate false hits on important characters
Richard M. Stallman <rms@gnu.org>
parents: 19301
diff changeset
219 (let (beg end found)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
220 (while (and (not (eobp))
19377
989d0412ada3 (c-end-of-statement-1): Eliminate false hits on important characters
Richard M. Stallman <rms@gnu.org>
parents: 19301
diff changeset
221 (progn
989d0412ada3 (c-end-of-statement-1): Eliminate false hits on important characters
Richard M. Stallman <rms@gnu.org>
parents: 19301
diff changeset
222 (setq beg (point))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
223 (c-forward-sexp 1)
19377
989d0412ada3 (c-end-of-statement-1): Eliminate false hits on important characters
Richard M. Stallman <rms@gnu.org>
parents: 19301
diff changeset
224 (setq end (point))
989d0412ada3 (c-end-of-statement-1): Eliminate false hits on important characters
Richard M. Stallman <rms@gnu.org>
parents: 19301
diff changeset
225 (goto-char beg)
989d0412ada3 (c-end-of-statement-1): Eliminate false hits on important characters
Richard M. Stallman <rms@gnu.org>
parents: 19301
diff changeset
226 (setq found nil)
989d0412ada3 (c-end-of-statement-1): Eliminate false hits on important characters
Richard M. Stallman <rms@gnu.org>
parents: 19301
diff changeset
227 (while (and (not found)
989d0412ada3 (c-end-of-statement-1): Eliminate false hits on important characters
Richard M. Stallman <rms@gnu.org>
parents: 19301
diff changeset
228 (re-search-forward "[;{}]" end t))
989d0412ada3 (c-end-of-statement-1): Eliminate false hits on important characters
Richard M. Stallman <rms@gnu.org>
parents: 19301
diff changeset
229 (if (not (c-in-literal beg))
989d0412ada3 (c-end-of-statement-1): Eliminate false hits on important characters
Richard M. Stallman <rms@gnu.org>
parents: 19301
diff changeset
230 (setq found t)))
989d0412ada3 (c-end-of-statement-1): Eliminate false hits on important characters
Richard M. Stallman <rms@gnu.org>
parents: 19301
diff changeset
231 (not found)))
989d0412ada3 (c-end-of-statement-1): Eliminate false hits on important characters
Richard M. Stallman <rms@gnu.org>
parents: 19301
diff changeset
232 (goto-char end))
989d0412ada3 (c-end-of-statement-1): Eliminate false hits on important characters
Richard M. Stallman <rms@gnu.org>
parents: 19301
diff changeset
233 (re-search-backward "[;{}]")
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
234 (forward-char 1))
19806
dc7a5df6e4b9 (c-end-of-statement-1): Wrap backward-up-list in a c-safe call so no
Richard M. Stallman <rms@gnu.org>
parents: 19377
diff changeset
235 (error
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
236 (let ((beg (point)))
19806
dc7a5df6e4b9 (c-end-of-statement-1): Wrap backward-up-list in a c-safe call so no
Richard M. Stallman <rms@gnu.org>
parents: 19377
diff changeset
237 (c-safe (backward-up-list -1))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
238 (let ((end (point)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
239 (goto-char beg)
19806
dc7a5df6e4b9 (c-end-of-statement-1): Wrap backward-up-list in a c-safe call so no
Richard M. Stallman <rms@gnu.org>
parents: 19377
diff changeset
240 (search-forward ";" end 'move)))
dc7a5df6e4b9 (c-end-of-statement-1): Wrap backward-up-list in a c-safe call so no
Richard M. Stallman <rms@gnu.org>
parents: 19377
diff changeset
241 )))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
242
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
243
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
244 (defun c-crosses-statement-barrier-p (from to)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
245 ;; Does buffer positions FROM to TO cross a C statement boundary?
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
246 (let ((here (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
247 (lim from)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
248 crossedp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
249 (condition-case ()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
250 (progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
251 (goto-char from)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
252 (while (and (not crossedp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
253 (< (point) to))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
254 (skip-chars-forward "^;{}:" (1- to))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
255 (if (not (c-in-literal lim))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
256 (progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
257 (if (memq (char-after) '(?\; ?{ ?}))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
258 (setq crossedp t)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
259 (if (eq (char-after) ?:)
18844
6b269c4ad2eb (c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents: 18720
diff changeset
260 (setq c-maybe-labelp t))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
261 (forward-char 1))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
262 (setq lim (point)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
263 (forward-char 1))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
264 (error (setq crossedp nil)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
265 (goto-char here)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
266 crossedp))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
267
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
268
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
269 (defun c-beginning-of-macro (&optional lim)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
270 ;; Go to the beginning of a cpp macro definition. Leaves point at
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
271 ;; the beginning of the macro and returns t if in a cpp macro
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
272 ;; definition, otherwise returns nil and leaves point unchanged.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
273 ;; `lim' is currently ignored, but the interface requires it.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
274 (let ((here (point)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
275 (beginning-of-line)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
276 (while (eq (char-before (1- (point))) ?\\)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
277 (forward-line -1))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
278 (back-to-indentation)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
279 (if (and (<= (point) here)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
280 (eq (char-after) ?#))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
281 t
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
282 (goto-char here)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
283 nil)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
284
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
285 ;; Skipping of "syntactic whitespace", defined as lexical whitespace,
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
286 ;; C and C++ style comments, and preprocessor directives. Search no
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
287 ;; farther back or forward than optional LIM. If LIM is omitted,
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
288 ;; `beginning-of-defun' is used for backward skipping, point-max is
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
289 ;; used for forward skipping.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
290
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
291 (defun c-forward-syntactic-ws (&optional lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
292 ;; Forward skip of syntactic whitespace for Emacs 19.
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
293 (let* ((here (point-max))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
294 (hugenum (point-max)))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
295 (while (/= here (point))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
296 (setq here (point))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
297 (c-forward-comment hugenum)
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
298 ;; skip preprocessor directives
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
299 (when (and (eq (char-after) ?#)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
300 (= (c-point 'boi) (point)))
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
301 (while (and (eq (char-before (c-point 'eol)) ?\\)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
302 (= (forward-line 1) 0)))
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
303 (end-of-line))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
304 )
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
305 (if lim (goto-char (min (point) lim)))))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
306
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
307 (defun c-backward-syntactic-ws (&optional lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
308 ;; Backward skip over syntactic whitespace for Emacs 19.
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
309 (let* ((here (point-min))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
310 (hugenum (- (point-max))))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
311 (while (/= here (point))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
312 (setq here (point))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
313 (c-forward-comment hugenum)
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
314 (c-beginning-of-macro))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
315 (if lim (goto-char (max (point) lim)))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
316
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
317
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
318 ;; Moving by tokens, where a token is defined as all symbols and
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
319 ;; identifiers which aren't syntactic whitespace (note that "->" is
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
320 ;; considered to be two tokens). Point is always either left at the
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
321 ;; beginning of a token or not moved at all. COUNT specifies the
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
322 ;; number of tokens to move; a negative COUNT moves in the opposite
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
323 ;; direction. A COUNT of 0 moves to the next token beginning only if
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
324 ;; not already at one. If BALANCED is true, move over balanced
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
325 ;; parens, otherwise move into them. Also, if BALANCED is true, never
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
326 ;; move out of an enclosing paren. LIM sets the limit for the
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
327 ;; movement and defaults to the point limit. Returns the number of
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
328 ;; tokens left to move (positive or negative). If BALANCED is true, a
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
329 ;; move over a balanced paren counts as one. Note that if COUNT is 0
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
330 ;; and no appropriate token beginning is found, 1 will be returned.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
331 ;; Thus, a return value of 0 guarantees that point is at the requested
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
332 ;; position and a return value less (without signs) than COUNT
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
333 ;; guarantees that point is at the beginning of some token.
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
334
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
335 (defun c-forward-token-1 (&optional count balanced lim)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
336 (or count (setq count 1))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
337 (if (< count 0)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
338 (- (c-backward-token-1 (- count) balanced lim))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
339 (let ((jump-syntax (if balanced
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
340 '(?w ?_ ?\( ?\) ?\" ?\\ ?/ ?$ ?')
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
341 '(?w ?_ ?\" ?\\ ?/ ?')))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
342 (last (point))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
343 (prev (point)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
344 (save-restriction
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
345 (if lim (narrow-to-region (point-min) lim))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
346 (if (/= (point)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
347 (progn (c-forward-syntactic-ws) (point)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
348 ;; Skip whitespace. Count this as a move if we did in fact
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
349 ;; move and aren't out of bounds.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
350 (or (eobp)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
351 (setq count (max (1- count) 0))))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
352 (if (and (= count 0)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
353 (or (and (memq (char-syntax (or (char-after) ? )) '(?w ?_))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
354 (memq (char-syntax (or (char-before) ? )) '(?w ?_)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
355 (eobp)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
356 ;; If count is zero we should jump if in the middle of a
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
357 ;; token or if there is whitespace between point and the
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
358 ;; following token beginning.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
359 (setq count 1))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
360 (if (eobp)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
361 (goto-char last)
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
362 ;; Avoid having the limit tests inside the loop.
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
363 (condition-case nil
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
364 (while (> count 0)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
365 (setq prev last
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
366 last (point))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
367 (if (memq (char-syntax (char-after)) jump-syntax)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
368 (goto-char (scan-sexps (point) 1))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
369 (forward-char))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
370 (c-forward-syntactic-ws lim)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
371 (setq count (1- count)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
372 (error (goto-char last)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
373 (when (eobp)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
374 (goto-char prev)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
375 (setq count (1+ count)))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
376 count)))
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
377
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
378 (defun c-backward-token-1 (&optional count balanced lim)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
379 (or count (setq count 1))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
380 (if (< count 0)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
381 (- (c-forward-token-1 (- count) balanced lim))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
382 (let ((jump-syntax (if balanced
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
383 '(?w ?_ ?\( ?\) ?\" ?\\ ?/ ?$ ?')
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
384 '(?w ?_ ?\" ?\\ ?/ ?')))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
385 last)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
386 (if (and (= count 0)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
387 (or (and (memq (char-syntax (or (char-after) ? )) '(?w ?_))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
388 (memq (char-syntax (or (char-before) ? )) '(?w ?_)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
389 (/= (point)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
390 (save-excursion (c-forward-syntactic-ws) (point)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
391 (eobp)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
392 ;; If count is zero we should jump if in the middle of a
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
393 ;; token or if there is whitespace between point and the
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
394 ;; following token beginning.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
395 (setq count 1))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
396 (save-restriction
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
397 (if lim (narrow-to-region lim (point-max)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
398 (or (bobp)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
399 (progn
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
400 ;; Avoid having the limit tests inside the loop.
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
401 (condition-case nil
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
402 (while (progn
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
403 (setq last (point))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
404 (> count 0))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
405 (c-backward-syntactic-ws lim)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
406 (if (memq (char-syntax (char-before)) jump-syntax)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
407 (goto-char (scan-sexps (point) -1))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
408 (backward-char))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
409 (setq count (1- count)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
410 (error (goto-char last)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
411 (if (bobp) (goto-char last)))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
412 count)))
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
413
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
414
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
415 ;; Return `c' if in a C-style comment, `c++' if in a C++ style
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
416 ;; comment, `string' if in a string literal, `pound' if on a
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
417 ;; preprocessor line, or nil if not in a comment at all. Optional LIM
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
418 ;; is used as the backward limit of the search. If omitted, or nil,
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
419 ;; `beginning-of-defun' is used."
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
420
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
421 (defun c-in-literal (&optional lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
422 ;; Determine if point is in a C++ literal. we cache the last point
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
423 ;; calculated if the cache is enabled
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
424 (if (and (vectorp c-in-literal-cache)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
425 (= (point) (aref c-in-literal-cache 0)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
426 (aref c-in-literal-cache 1)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
427 (let ((rtn (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
428 (let* ((lim (or lim (c-point 'bod)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
429 (state (parse-partial-sexp lim (point))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
430 (cond
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
431 ((nth 3 state) 'string)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
432 ((nth 4 state) (if (nth 7 state) 'c++ 'c))
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
433 ((c-beginning-of-macro lim) 'pound)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
434 (t nil))))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
435 ;; cache this result if the cache is enabled
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
436 (if (not c-in-literal-cache)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
437 (setq c-in-literal-cache (vector (point) rtn)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
438 rtn)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
439
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
440 ;; XEmacs has a built-in function that should make this much quicker.
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
441 ;; I don't think we even need the cache, which makes our lives more
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
442 ;; complicated anyway. In this case, lim is ignored.
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
443 (defun c-fast-in-literal (&optional lim)
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
444 (let ((context (buffer-syntactic-context)))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
445 (cond
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
446 ((eq context 'string) 'string)
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
447 ((eq context 'comment) 'c++)
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
448 ((eq context 'block-comment) 'c)
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
449 ((save-excursion (c-beginning-of-macro lim)) 'pound))))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
450
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
451 (if (fboundp 'buffer-syntactic-context)
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
452 (defalias 'c-in-literal 'c-fast-in-literal))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
453
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
454 (defun c-literal-limits (&optional lim near not-in-delimiter)
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
455 ;; Returns a cons of the beginning and end positions of the comment
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
456 ;; or string surrounding point (including both delimiters), or nil
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
457 ;; if point isn't in one. If LIM is non-nil, it's used as the
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
458 ;; "safe" position to start parsing from. If NEAR is non-nil, then
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
459 ;; the limits of any literal next to point is returned. "Next to"
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
460 ;; means there's only [ \t] between point and the literal. The
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
461 ;; search for such a literal is done first in forward direction. If
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
462 ;; NOT-IN-DELIMITER is non-nil, the case when point is inside a
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
463 ;; starting delimiter won't be recognized. This only has effect for
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
464 ;; comments, which have starting delimiters with more than one
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
465 ;; character.
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
466 (save-excursion
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
467 (let* ((pos (point))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
468 (lim (or lim (c-point 'bod)))
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
469 (state (parse-partial-sexp lim (point))))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
470 (cond ((nth 3 state)
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
471 ;; String. Search backward for the start.
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
472 (while (nth 3 state)
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
473 (search-backward (make-string 1 (nth 3 state)))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
474 (setq state (parse-partial-sexp lim (point))))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
475 (cons (point) (or (c-safe (c-forward-sexp 1) (point))
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
476 (point-max))))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
477 ((nth 7 state)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
478 ;; Line comment. Search from bol for the comment starter.
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
479 (beginning-of-line)
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
480 (setq state (parse-partial-sexp lim (point))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
481 lim (point))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
482 (while (not (nth 7 state))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
483 (search-forward "//") ; Should never fail.
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
484 (setq state (parse-partial-sexp
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
485 lim (point) nil nil state)
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
486 lim (point)))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
487 (backward-char 2)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
488 (cons (point) (progn (c-forward-comment 1) (point))))
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
489 ((nth 4 state)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
490 ;; Block comment. Search backward for the comment starter.
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
491 (while (nth 4 state)
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
492 (search-backward "/*") ; Should never fail.
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
493 (setq state (parse-partial-sexp lim (point))))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
494 (cons (point) (progn (c-forward-comment 1) (point))))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
495 ((and (not not-in-delimiter)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
496 (not (nth 5 state))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
497 (eq (char-before) ?/)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
498 (looking-at "[/*]"))
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
499 ;; We're standing in a comment starter.
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
500 (backward-char 1)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
501 (cons (point) (progn (c-forward-comment 1) (point))))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
502 (near
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
503 (goto-char pos)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
504 ;; Search forward for a literal.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
505 (skip-chars-forward " \t")
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
506 (cond
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
507 ((eq (char-syntax (or (char-after) ?\ )) ?\") ; String.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
508 (cons (point) (or (c-safe (c-forward-sexp 1) (point))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
509 (point-max))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
510 ((looking-at "/[/*]") ; Line or block comment.
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
511 (cons (point) (progn (c-forward-comment 1) (point))))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
512 (t
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
513 ;; Search backward.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
514 (skip-chars-backward " \t")
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
515 (let ((end (point)) beg)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
516 (cond
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
517 ((eq (char-syntax (or (char-before) ?\ )) ?\") ; String.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
518 (setq beg (c-safe (c-backward-sexp 1) (point))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
519 ((and (c-safe (forward-char -2) t)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
520 (looking-at "*/"))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
521 ;; Block comment. Due to the nature of line
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
522 ;; comments, they will always be covered by the
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
523 ;; normal case above.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
524 (goto-char end)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
525 (c-forward-comment -1)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
526 ;; If LIM is bogus, beg will be bogus.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
527 (setq beg (point))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
528 (if beg (cons beg end))))))
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
529 ))))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
530
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
531 (defun c-literal-limits-fast (&optional lim near not-in-delimiter)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
532 ;; Like c-literal-limits, but for emacsen whose `parse-partial-sexp'
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
533 ;; returns the pos of the comment start.
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
534 (save-excursion
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
535 (let* ((pos (point))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
536 (lim (or lim (c-point 'bod)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
537 (state (parse-partial-sexp lim (point))))
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
538 (cond ((nth 3 state) ; String.
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
539 (goto-char (nth 8 state))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
540 (cons (point) (or (c-safe (c-forward-sexp 1) (point))
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
541 (point-max))))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
542 ((nth 4 state) ; Comment.
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
543 (goto-char (nth 8 state))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
544 (cons (point) (progn (c-forward-comment 1) (point))))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
545 ((and (not not-in-delimiter)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
546 (not (nth 5 state))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
547 (eq (char-before) ?/)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
548 (looking-at "[/*]"))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
549 ;; We're standing in a comment starter.
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
550 (backward-char 1)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
551 (cons (point) (progn (c-forward-comment 1) (point))))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
552 (near
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
553 (goto-char pos)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
554 ;; Search forward for a literal.
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
555 (skip-chars-forward " \t")
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
556 (cond
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
557 ((eq (char-syntax (or (char-after) ?\ )) ?\") ; String.
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
558 (cons (point) (or (c-safe (c-forward-sexp 1) (point))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
559 (point-max))))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
560 ((looking-at "/[/*]") ; Line or block comment.
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
561 (cons (point) (progn (c-forward-comment 1) (point))))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
562 (t
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
563 ;; Search backward.
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
564 (skip-chars-backward " \t")
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
565 (let ((end (point)) beg)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
566 (cond
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
567 ((eq (char-syntax (or (char-before) ?\ )) ?\") ; String.
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
568 (setq beg (c-safe (c-backward-sexp 1) (point))))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
569 ((and (c-safe (forward-char -2) t)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
570 (looking-at "*/"))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
571 ;; Block comment. Due to the nature of line
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
572 ;; comments, they will always be covered by the
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
573 ;; normal case above.
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
574 (goto-char end)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
575 (c-forward-comment -1)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
576 ;; If LIM is bogus, beg will be bogus.
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
577 (setq beg (point))))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
578 (if beg (cons beg end))))))
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
579 ))))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
580
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
581 (if (c-safe (> (length (save-excursion (parse-partial-sexp 1 1))) 8))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
582 (defalias 'c-literal-limits 'c-literal-limits-fast))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
583
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
584 (defun c-collect-line-comments (range)
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
585 ;; If the argument is a cons of two buffer positions (such as
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
586 ;; returned by c-literal-limits), and that range contains a C++
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
587 ;; style line comment, then an extended range is returned that
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
588 ;; contains all adjacent line comments (i.e. all comments that
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
589 ;; starts in the same column with no empty lines or non-whitespace
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
590 ;; characters between them). Otherwise the argument is returned.
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
591 (save-excursion
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
592 (condition-case nil
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
593 (if (and (consp range) (progn
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
594 (goto-char (car range))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
595 (looking-at "//")))
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
596 (let ((col (current-column))
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
597 (beg (point))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
598 (bopl (c-point 'bopl))
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
599 (end (cdr range)))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
600 ;; Got to take care in the backward direction to handle
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
601 ;; comments which are preceded by code.
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
602 (while (and (c-forward-comment -1)
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
603 (>= (point) bopl)
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
604 (looking-at "//")
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
605 (= col (current-column)))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
606 (setq beg (point)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
607 bopl (c-point 'bopl)))
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
608 (goto-char end)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
609 (while (and (progn (skip-chars-forward " \t")
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
610 (looking-at "//"))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
611 (= col (current-column))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
612 (prog1 (zerop (forward-line 1))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
613 (setq end (point)))))
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
614 (cons beg end))
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
615 range)
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
616 (error range))))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
617
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
618 (defun c-literal-type (range)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
619 ;; Convenience function that given the result of c-literal-limits,
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
620 ;; returns nil or the type of literal that the range surrounds.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
621 ;; It's much faster than using c-in-literal and is intended to be
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
622 ;; used when you need both the type of a literal and its limits.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
623 (if (consp range)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
624 (save-excursion
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
625 (goto-char (car range))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
626 (cond ((eq (char-syntax (or (char-after) ?\ )) ?\") 'string)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
627 ((looking-at "//") 'c++)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
628 (t 'c))) ; Assuming the range is valid.
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
629 range))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
630
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
631
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
632
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
633 ;; utilities for moving and querying around syntactic elements
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
634 (defvar c-parsing-error nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
635
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
636 (defun c-parse-state ()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
637 ;; Finds and records all open parens between some important point
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
638 ;; earlier in the file and point.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
639 ;;
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
640 ;; if there's a state cache, return it
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
641 (if c-state-cache c-state-cache
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
642 (let* (at-bob
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
643 (pos (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
644 ;; go back 2 bods, but ignore any bogus positions
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
645 ;; returned by beginning-of-defun (i.e. open paren
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
646 ;; in column zero)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
647 (let ((cnt 2))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
648 (while (not (or at-bob (zerop cnt)))
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
649 (goto-char (c-point 'bod))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
650 (if (and
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
651 (eq (char-after) ?\{)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
652 ;; The following catches an obscure special
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
653 ;; case where the brace is preceded by an
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
654 ;; open paren. That can only legally occur
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
655 ;; with blocks inside expressions and in
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
656 ;; Pike special brace lists. Even so, this
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
657 ;; test is still bogus then, but hopefully
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
658 ;; good enough. (We don't want to use
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
659 ;; up-list here since it might be slow.)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
660 (save-excursion
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
661 (c-backward-syntactic-ws)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
662 (not (eq (char-before) ?\())))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
663 (setq cnt (1- cnt)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
664 (if (bobp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
665 (setq at-bob t))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
666 (point)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
667 (here (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
668 ;;(skip-chars-forward " \t}")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
669 (point)))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
670 (last-bod here) (last-pos pos)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
671 placeholder state sexp-end)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
672 ;; cache last bod position
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
673 (while (catch 'backup-bod
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
674 (setq state nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
675 (while (and pos (< pos here))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
676 (setq last-pos pos)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
677 (if (and (setq pos (c-safe (scan-lists pos 1 -1)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
678 (<= pos here))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
679 (progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
680 (setq sexp-end (c-safe (scan-sexps (1- pos) 1)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
681 (if (and sexp-end
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
682 (<= sexp-end here))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
683 ;; we want to record both the start and end
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
684 ;; of this sexp, but we only want to record
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
685 ;; the last-most of any of them before here
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
686 (progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
687 (if (eq (char-after (1- pos)) ?\{)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
688 (setq state (cons (cons (1- pos) sexp-end)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
689 (if (consp (car state))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
690 (cdr state)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
691 state))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
692 (setq pos sexp-end))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
693 ;; we're contained in this sexp so put pos on
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
694 ;; front of list
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
695 (setq state (cons (1- pos) state))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
696 ;; something bad happened. check to see if we
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
697 ;; crossed an unbalanced close brace. if so, we
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
698 ;; didn't really find the right `important bufpos'
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
699 ;; so lets back up and try again
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
700 (if (and (not pos) (not at-bob)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
701 (setq placeholder
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
702 (c-safe (scan-lists last-pos 1 1)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
703 ;;(char-after (1- placeholder))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
704 (<= placeholder here)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
705 (eq (char-after (1- placeholder)) ?\}))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
706 (while t
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
707 (setq last-bod (c-safe (scan-lists last-bod -1 1)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
708 (if (not last-bod)
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
709 (save-excursion
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
710 ;; bogus, but what can we do here?
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
711 (goto-char placeholder)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
712 (beginning-of-line)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
713 (setq c-parsing-error
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
714 (format "\
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
715 Unbalanced close brace at line %d" (1+ (count-lines 1 (point)))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
716 (throw 'backup-bod nil))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
717 (setq at-bob (= last-bod (point-min))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
718 pos last-bod)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
719 (if (= (char-after last-bod) ?\{)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
720 (throw 'backup-bod t)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
721 )) ;end-if
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
722 )) ;end-while
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
723 nil))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
724 state)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
725
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
726 (defun c-whack-state (bufpos state)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
727 ;; whack off any state information that appears on STATE which lies
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
728 ;; after the bounds of BUFPOS.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
729 (let (newstate car)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
730 (while state
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
731 (setq car (car state)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
732 state (cdr state))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
733 (if (consp car)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
734 ;; just check the car, because in a balanced brace
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
735 ;; expression, it must be impossible for the corresponding
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
736 ;; close brace to be before point, but the open brace to be
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
737 ;; after.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
738 (if (<= bufpos (car car))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
739 nil ; whack it off
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
740 ;; its possible that the open brace is before bufpos, but
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
741 ;; the close brace is after. In that case, convert this
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
742 ;; to a non-cons element.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
743 (if (<= bufpos (cdr car))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
744 (setq newstate (append newstate (list (car car))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
745 ;; we know that both the open and close braces are
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
746 ;; before bufpos, so we also know that everything else
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
747 ;; on state is before bufpos, so we can glom up the
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
748 ;; whole thing and exit.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
749 (setq newstate (append newstate (list car) state)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
750 state nil)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
751 (if (<= bufpos car)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
752 nil ; whack it off
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
753 ;; it's before bufpos, so everything else should too
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
754 (setq newstate (append newstate (list car) state)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
755 state nil))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
756 newstate))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
757
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
758 (defun c-hack-state (bufpos which state)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
759 ;; Using BUFPOS buffer position, and WHICH (must be 'open or
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
760 ;; 'close), hack the c-parse-state STATE and return the results.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
761 (if (eq which 'open)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
762 (let ((car (car state)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
763 (if (or (null car)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
764 (consp car)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
765 (/= bufpos car))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
766 (cons bufpos state)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
767 state))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
768 (if (not (eq which 'close))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
769 (error "c-hack-state, bad argument: %s" which))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
770 ;; 'close brace
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
771 (let ((car (car state))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
772 (cdr (cdr state)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
773 (if (consp car)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
774 (setq car (car cdr)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
775 cdr (cdr cdr)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
776 ;; TBD: is this test relevant???
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
777 (if (consp car)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
778 state ;on error, don't change
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
779 ;; watch out for balanced expr already on cdr of list
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
780 (cons (cons car bufpos)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
781 (if (consp (car cdr))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
782 (cdr cdr) cdr))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
783 ))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
784
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
785 (defun c-adjust-state (from to shift state)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
786 ;; Adjust all points in state that lie in the region FROM..TO by
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
787 ;; SHIFT amount.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
788 (mapcar
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
789 (function
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
790 (lambda (e)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
791 (if (consp e)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
792 (let ((car (car e))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
793 (cdr (cdr e)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
794 (if (and (<= from car) (< car to))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
795 (setcar e (+ shift car)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
796 (if (and (<= from cdr) (< cdr to))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
797 (setcdr e (+ shift cdr))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
798 (if (and (<= from e) (< e to))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
799 (setq e (+ shift e))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
800 e))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
801 state))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
802
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
803
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
804 (defun c-beginning-of-inheritance-list (&optional lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
805 ;; Go to the first non-whitespace after the colon that starts a
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
806 ;; multiple inheritance introduction. Optional LIM is the farthest
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
807 ;; back we should search.
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
808 (let* ((lim (or lim (c-point 'bod)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
809 (placeholder (progn
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
810 (back-to-indentation)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
811 (point)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
812 (chr (char-after)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
813 (c-backward-syntactic-ws lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
814 (while (and (> (point) lim)
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
815 (or (eq chr ?,)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
816 (memq (char-before) '(?, ?:)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
817 (progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
818 (beginning-of-line)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
819 (setq placeholder (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
820 (skip-chars-forward " \t")
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
821 (setq chr (char-after))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
822 (not (looking-at c-class-key))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
823 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
824 (c-backward-syntactic-ws lim))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
825 (goto-char placeholder)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
826 (skip-chars-forward "^:" (c-point 'eol))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
827
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
828 (defun c-in-method-def-p ()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
829 ;; Return nil if we aren't in a method definition, otherwise the
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
830 ;; position of the initial [+-].
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
831 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
832 (beginning-of-line)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
833 (and c-method-key
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
834 (looking-at c-method-key)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
835 (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
836 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
837
24335
0c4688f9a396 Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents: 24282
diff changeset
838 (defun c-at-toplevel-p ()
0c4688f9a396 Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents: 24282
diff changeset
839 "Return a determination as to whether point is at the `top-level'.
0c4688f9a396 Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents: 24282
diff changeset
840 Being at the top-level means that point is either outside any
0c4688f9a396 Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents: 24282
diff changeset
841 enclosing block (such function definition), or inside a class
0c4688f9a396 Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents: 24282
diff changeset
842 definition, but outside any method blocks.
0c4688f9a396 Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents: 24282
diff changeset
843
0c4688f9a396 Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents: 24282
diff changeset
844 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
845 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
846 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
847 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
848 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
849 element is the buffer position of the enclosing class's opening
0c4688f9a396 Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents: 24282
diff changeset
850 brace."
0c4688f9a396 Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents: 24282
diff changeset
851 (let ((state (c-parse-state)))
0c4688f9a396 Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents: 24282
diff changeset
852 (or (not (c-most-enclosing-brace state))
0c4688f9a396 Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents: 24282
diff changeset
853 (c-search-uplist-for-classkey state))))
0c4688f9a396 Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents: 24282
diff changeset
854
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
855 (defun c-just-after-func-arglist-p (&optional containing)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
856 ;; Return t if we are between a function's argument list closing
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
857 ;; paren and its opening brace. Note that the list close brace
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
858 ;; could be followed by a "const" specifier or a member init hanging
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
859 ;; colon. Optional CONTAINING is position of containing s-exp open
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
860 ;; brace. If not supplied, point is used as search start.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
861 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
862 (c-backward-syntactic-ws)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
863 (let ((checkpoint (or containing (point))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
864 (goto-char checkpoint)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
865 ;; could be looking at const specifier
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
866 (if (and (eq (char-before) ?t)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
867 (forward-word -1)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
868 (looking-at "\\<const\\>"))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
869 (c-backward-syntactic-ws)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
870 ;; otherwise, we could be looking at a hanging member init
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
871 ;; colon
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
872 (goto-char checkpoint)
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
873 (while (eq (char-before) ?,)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
874 ;; this will catch member inits with multiple
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
875 ;; line arglists
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
876 (forward-char -1)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
877 (c-backward-syntactic-ws (c-point 'bol))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
878 (if (eq (char-before) ?\))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
879 (c-backward-sexp 2)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
880 (c-backward-sexp 1))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
881 (c-backward-syntactic-ws))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
882 (if (and (eq (char-before) ?:)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
883 (progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
884 (forward-char -1)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
885 (c-backward-syntactic-ws)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
886 (looking-at "[ \t\n]*:\\([^:]+\\|$\\)")))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
887 nil
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
888 (goto-char checkpoint))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
889 )
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
890 (and (eq (char-before) ?\))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
891 ;; check if we are looking at a method def
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
892 (or (not c-method-key)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
893 (progn
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
894 (c-forward-sexp -1)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
895 (forward-char -1)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
896 (c-backward-syntactic-ws)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
897 (not (or (memq (char-before) '(?- ?+))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
898 ;; or a class category
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
899 (progn
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
900 (c-forward-sexp -2)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
901 (looking-at c-class-key))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
902 )))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
903 )))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
904
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
905 ;; defuns to look backwards for things
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
906 (defun c-backward-to-start-of-do (&optional lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
907 ;; Move to the start of the last "unbalanced" do expression.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
908 ;; Optional LIM is the farthest back to search. If none is found,
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
909 ;; nil is returned and point is left unchanged, otherwise t is returned.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
910 (let ((do-level 1)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
911 (case-fold-search nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
912 (lim (or lim (c-point 'bod)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
913 (here (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
914 foundp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
915 (while (not (zerop do-level))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
916 ;; we protect this call because trying to execute this when the
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
917 ;; while is not associated with a do will throw an error
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
918 (condition-case nil
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
919 (progn
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
920 (c-backward-sexp 1)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
921 (cond
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
922 ;; break infloop for illegal C code
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
923 ((bobp) (setq do-level 0))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
924 ((memq (c-in-literal lim) '(c c++)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
925 ((looking-at "while\\b[^_]")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
926 (setq do-level (1+ do-level)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
927 ((looking-at "do\\b[^_]")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
928 (if (zerop (setq do-level (1- do-level)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
929 (setq foundp t)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
930 ((<= (point) lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
931 (setq do-level 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
932 (goto-char lim))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
933 (error
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
934 (goto-char lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
935 (setq do-level 0))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
936 (if (not foundp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
937 (goto-char here))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
938 foundp))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
939
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
940 (defun c-backward-to-start-of-if (&optional lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
941 ;; Move to the start of the last "unbalanced" if and return t. If
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
942 ;; none is found, and we are looking at an if clause, nil is
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
943 ;; returned.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
944 (let ((if-level 1)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
945 (here (c-point 'bol))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
946 (case-fold-search nil)
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
947 (lim (or (and lim (>= (point) lim) lim)
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
948 (c-point 'bod)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
949 (at-if (looking-at "if\\b[^_]")))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
950 (catch 'orphan-if
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
951 (while (and (not (bobp))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
952 (not (zerop if-level)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
953 (c-backward-syntactic-ws)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
954 (condition-case nil
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
955 (c-backward-sexp 1)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
956 (error
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
957 (unless at-if
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
958 (goto-char here)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
959 (c-beginning-of-statement-1)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
960 (setq c-parsing-error
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
961 (format "No matching `if' found for `else' on line %d"
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
962 (1+ (count-lines 1 here))))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
963 (throw 'orphan-if nil))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
964 (cond
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
965 ((looking-at "else\\b[^_]")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
966 (setq if-level (1+ if-level)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
967 ((looking-at "if\\b[^_]")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
968 ;; check for else if... skip over
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
969 (let ((here (point)))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
970 (c-safe (c-forward-sexp -1))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
971 (if (looking-at "\\<else\\>[ \t]+\\<if\\>[^_]")
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
972 nil
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
973 (setq if-level (1- if-level))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
974 (goto-char here))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
975 ((< (point) lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
976 (setq if-level 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
977 (goto-char lim))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
978 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
979 t)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
980
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
981 (defun c-skip-conditional ()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
982 ;; skip forward over conditional at point, including any predicate
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
983 ;; statements in parentheses. No error checking is performed.
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
984 (c-forward-sexp (cond
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
985 ;; else if()
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
986 ((looking-at "\\<else\\>[ \t]+\\<if\\>\\([^_]\\|$\\)") 3)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
987 ;; do, else, try, finally
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
988 ((looking-at
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
989 "\\<\\(do\\|else\\|try\\|finally\\)\\>\\([^_]\\|$\\)")
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
990 1)
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
991 ;; for, if, while, switch, catch, synchronized, foreach
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
992 (t 2))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
993
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
994 (defun c-beginning-of-closest-statement (&optional lim)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
995 ;; Go back to the closest preceding statement start.
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
996 (let ((start (point))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
997 (label-re (concat c-label-key "\\|"
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
998 c-switch-label-key))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
999 stmtbeg)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1000 (if c-access-key
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1001 (setq label-re (concat label-re "\\|" c-access-key)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1002 (c-beginning-of-statement-1 lim)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1003 (while (and (when (<= (point) start)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1004 (setq stmtbeg (point)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1005 (cond
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1006 ((looking-at label-re)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1007 ;; Skip a label.
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1008 (goto-char (match-end 0))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1009 t)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1010 ((looking-at c-conditional-key)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1011 ;; Skip a conditional statement.
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1012 (c-safe (c-skip-conditional) t))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1013 (t nil)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1014 (c-forward-syntactic-ws start))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1015 (if stmtbeg
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1016 (goto-char stmtbeg))))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1017
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1018 (defun c-beginning-of-member-init-list (&optional limit)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1019 ;; Goes to the beginning of a member init list (i.e. just after the
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1020 ;; ':') if inside one. Returns t in that case, nil otherwise.
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1021 (or limit
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1022 (setq limit (point-min)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1023 (skip-chars-forward " \t")
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1024 (if (eq (char-after) ?,)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1025 (forward-char 1)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1026 (c-backward-syntactic-ws limit))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1027 (c-with-syntax-table (if (c-major-mode-is 'c++-mode)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1028 c++-template-syntax-table
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1029 (syntax-table))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1030 (while (and (< limit (point))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1031 (eq (char-before) ?,))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1032 ;; this will catch member inits with multiple
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1033 ;; line arglists
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1034 (forward-char -1)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1035 (c-backward-syntactic-ws)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1036 (if (eq (char-before) ?\))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1037 (c-backward-sexp 2)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1038 (c-backward-sexp 1))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1039 ;; Skip over any template arg to the class.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1040 (if (eq (char-after) ?<)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1041 (c-backward-sexp 1))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1042 ;; Skip backwards over a fully::qualified::name.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1043 (c-backward-syntactic-ws limit)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1044 (while (and (eq (char-before) ?:)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1045 (save-excursion
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1046 (forward-char -1)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1047 (eq (char-before) ?:)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1048 (backward-char 2)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1049 (c-backward-sexp 1))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1050 ;; now continue checking
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1051 (c-backward-syntactic-ws limit)))
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1052 (and (< limit (point))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1053 (eq (char-before) ?:)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1054
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1055 (defun c-skip-case-statement-forward (state &optional lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1056 ;; skip forward over case/default bodies, with optional maximal
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1057 ;; limit. if no next case body is found, nil is returned and point
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1058 ;; is not moved
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1059 (let ((lim (or lim (point-max)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1060 (here (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1061 donep foundp bufpos
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1062 (safepos (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1063 (balanced (car state)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1064 ;; search until we've passed the limit, or we've found our match
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1065 (while (and (< (point) lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1066 (not donep))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1067 (setq safepos (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1068 ;; see if we can find a case statement, not in a literal
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1069 (if (and (re-search-forward c-switch-label-key lim 'move)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1070 (setq bufpos (match-beginning 0))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1071 (not (c-in-literal safepos))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1072 (/= bufpos here))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1073 ;; if we crossed into a balanced sexp, we know the case is
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1074 ;; not part of our switch statement, so just bound over the
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1075 ;; sexp and keep looking.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1076 (if (and (consp balanced)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1077 (> bufpos (car balanced))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1078 (< bufpos (cdr balanced)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1079 (goto-char (cdr balanced))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1080 (goto-char bufpos)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1081 (setq donep t
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1082 foundp t))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1083 (if (not foundp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1084 (goto-char here))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1085 foundp))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1086
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1087 (defun c-search-uplist-for-classkey (brace-state)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1088 ;; search for the containing class, returning a 2 element vector if
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1089 ;; found. aref 0 contains the bufpos of the boi of the class key
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1090 ;; line, and aref 1 contains the bufpos of the open brace.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1091 (if (null brace-state)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1092 ;; no brace-state means we cannot be inside a class
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1093 nil
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1094 (let ((carcache (car brace-state))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1095 search-start search-end)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1096 (if (consp carcache)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1097 ;; a cons cell in the first element means that there is some
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1098 ;; balanced sexp before the current bufpos. this we can
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1099 ;; ignore. the nth 1 and nth 2 elements define for us the
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1100 ;; search boundaries
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1101 (setq search-start (nth 2 brace-state)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1102 search-end (nth 1 brace-state))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1103 ;; if the car was not a cons cell then nth 0 and nth 1 define
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1104 ;; for us the search boundaries
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1105 (setq search-start (nth 1 brace-state)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1106 search-end (nth 0 brace-state)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1107 ;; search-end cannot be a cons cell
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1108 (and (consp search-end)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1109 (error "consp search-end: %s" search-end))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1110 ;; if search-end is nil, or if the search-end character isn't an
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1111 ;; open brace, we are definitely not in a class
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1112 (if (or (not search-end)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1113 (< search-end (point-min))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1114 (not (eq (char-after search-end) ?{)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1115 nil
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1116 ;; now, we need to look more closely at search-start. if
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1117 ;; search-start is nil, then our start boundary is really
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1118 ;; point-min.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1119 (if (not search-start)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1120 (setq search-start (point-min))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1121 ;; if search-start is a cons cell, then we can start
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1122 ;; searching from the end of the balanced sexp just ahead of
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1123 ;; us
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1124 (if (consp search-start)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1125 (setq search-start (cdr search-start))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1126 ;; now we can do a quick regexp search from search-start to
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1127 ;; search-end and see if we can find a class key. watch for
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1128 ;; class like strings in literals
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1129 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1130 (save-restriction
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1131 (goto-char search-start)
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1132 (let ((search-key (concat c-class-key "\\|" c-extra-toplevel-key))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1133 foundp class match-end)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1134 (if c-inexpr-class-key
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1135 (setq search-key (concat search-key "\\|"
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1136 c-inexpr-class-key)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1137 (while (and (not foundp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1138 (progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1139 (c-forward-syntactic-ws)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1140 (> search-end (point)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1141 (re-search-forward search-key search-end t))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1142 (setq class (match-beginning 0)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1143 match-end (match-end 0))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1144 (if (c-in-literal search-start)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1145 nil ; its in a comment or string, ignore
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1146 (goto-char class)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1147 (skip-chars-forward " \t\n")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1148 (setq foundp (vector (c-point 'boi) search-end))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1149 (cond
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1150 ;; check for embedded keywords
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1151 ((let ((char (char-after (1- class))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1152 (and char
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1153 (memq (char-syntax char) '(?w ?_))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1154 (goto-char match-end)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1155 (setq foundp nil))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1156 ;; make sure we're really looking at the start of a
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1157 ;; class definition, and not a forward decl, return
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1158 ;; arg, template arg list, or an ObjC or Java method.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1159 ((and c-method-key
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1160 (re-search-forward c-method-key search-end t)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1161 (not (c-in-literal class)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1162 (setq foundp nil))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1163 ;; Check if this is an anonymous inner class.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1164 ((and c-inexpr-class-key
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1165 (looking-at c-inexpr-class-key))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1166 (while (and (= (c-forward-token-1 1 t) 0)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1167 (looking-at "(\\|\\w\\|\\s_\\|\\.")))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1168 (if (eq (point) search-end)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1169 ;; We're done. Just trap this case in the cond.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1170 nil
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1171 ;; False alarm; all conditions aren't satisfied.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1172 (setq foundp nil)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1173 ;; Its impossible to define a regexp for this, and
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1174 ;; nearly so to do it programmatically.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1175 ;;
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1176 ;; ; picks up forward decls
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1177 ;; = picks up init lists
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1178 ;; ) picks up return types
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1179 ;; > picks up templates, but remember that we can
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1180 ;; inherit from templates!
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1181 ((let ((skipchars "^;=)"))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1182 ;; try to see if we found the `class' keyword
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1183 ;; inside a template arg list
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1184 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1185 (skip-chars-backward "^<>" search-start)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1186 (if (eq (char-before) ?<)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1187 (setq skipchars (concat skipchars ">"))))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1188 (while (progn
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1189 (skip-chars-forward skipchars search-end)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1190 (c-in-literal class))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1191 (forward-char))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1192 (/= (point) search-end))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1193 (setq foundp nil))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1194 )))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1195 foundp))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1196 )))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1197
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1198 (defun c-inside-bracelist-p (containing-sexp brace-state)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1199 ;; return the buffer position of the beginning of the brace list
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1200 ;; statement if we're inside a brace list, otherwise return nil.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1201 ;; CONTAINING-SEXP is the buffer pos of the innermost containing
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1202 ;; paren. BRACE-STATE is the remainder of the state of enclosing
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1203 ;; braces
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1204 ;;
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1205 ;; N.B.: This algorithm can potentially get confused by cpp macros
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1206 ;; places in inconvenient locations. Its a trade-off we make for
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1207 ;; speed.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1208 (or
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1209 ;; this will pick up enum lists
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
1210 (c-safe
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
1211 (save-excursion
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
1212 (goto-char containing-sexp)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1213 (c-forward-sexp -1)
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
1214 (let (bracepos)
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
1215 (if (and (or (looking-at "enum[\t\n ]+")
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1216 (progn (c-forward-sexp -1)
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
1217 (looking-at "enum[\t\n ]+")))
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
1218 (setq bracepos (c-safe (scan-lists (point) 1 -1)))
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
1219 (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
1220 (- bracepos 2))))
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
1221 (point)))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1222 ;; 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
1223 (save-excursion
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1224 (let ((class-key
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1225 ;; 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
1226 ;; check for the class key here.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1227 (and (c-major-mode-is 'pike-mode)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1228 (concat c-class-key "\\|" c-extra-toplevel-key)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1229 bufpos lim braceassignp)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1230 (while (and (not bufpos)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1231 containing-sexp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1232 (if (consp containing-sexp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1233 (setq containing-sexp (car brace-state)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1234 brace-state (cdr brace-state))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1235 (goto-char containing-sexp)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1236 (if (c-looking-at-inexpr-block)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1237 ;; We're in an in-expression block of some kind. Do
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1238 ;; not check nesting.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1239 (setq containing-sexp nil)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1240 ;; 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
1241 ;; this statement, but watch out for operator=
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1242 (setq lim (if (consp (car brace-state))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1243 (cdr (car brace-state))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1244 (car brace-state))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1245 braceassignp 'dontknow)
25178
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
1246 (c-backward-token-1 1 t lim)
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
1247 ;; Checks to do only on the first sexp before the brace.
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
1248 (when (and (c-major-mode-is 'java-mode)
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
1249 (eq (char-after) ?\[))
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
1250 ;; 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
1251 ;; 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
1252 ;; earlier.
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
1253 (while (eq braceassignp 'dontknow)
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
1254 (setq braceassignp
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
1255 (cond ((/= (c-backward-token-1 1 t lim) 0) nil)
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1256 ((looking-at "new\\>[^_]") t)
25178
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
1257 ((looking-at "\\sw\\|\\s_\\|[.[]")
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
1258 ;; 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
1259 ;; identifier (may contain "." in Java)
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
1260 ;; or another "[]" sexp.
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
1261 'dontknow)
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
1262 (t nil)))))
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
1263 ;; 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
1264 ;; beginning of the statement.
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
1265 (while (eq braceassignp 'dontknow)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1266 (cond ((eq (char-after) ?\;)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1267 (setq braceassignp nil))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1268 ((and class-key
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1269 (looking-at class-key))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1270 (setq braceassignp nil))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1271 ((eq (char-after) ?=)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1272 ;; 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
1273 ;; 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
1274 (setq braceassignp 'maybe)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1275 (while (and (eq braceassignp 'maybe)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1276 (zerop (c-backward-token-1 1 t lim)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1277 (setq braceassignp
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1278 (cond
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1279 ;; Check for operator =
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1280 ((looking-at "operator\\>") nil)
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1281 ;; Check for `<opchar>= in Pike.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1282 ((and (c-major-mode-is 'pike-mode)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1283 (or (eq (char-after) ?`)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1284 ;; Special case for Pikes
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1285 ;; `[]=, since '[' is not in
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1286 ;; the punctuation class.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1287 (and (eq (char-after) ?\[)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1288 (eq (char-before) ?`))))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1289 nil)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1290 ((looking-at "\\s.") 'maybe)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1291 ;; 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
1292 ;; argument assignment
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1293 ((and (c-major-mode-is 'c++-mode)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1294 (save-excursion
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1295 (let ((here (point))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1296 (pos< (progn
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1297 (skip-chars-backward "^<>")
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1298 (point))))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1299 (and (eq (char-before) ?<)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1300 (not (c-crosses-statement-barrier-p
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1301 pos< here))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1302 (not (c-in-literal))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1303 ))))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1304 nil)
25178
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
1305 (t t))))))
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
1306 (if (and (eq braceassignp 'dontknow)
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
1307 (/= (c-backward-token-1 1 t lim) 0))
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
1308 (setq braceassignp nil)))
1dc57e616e8d (c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents: 24335
diff changeset
1309 (if (not braceassignp)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1310 (if (eq (char-after) ?\;)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1311 ;; 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
1312 (setq containing-sexp nil)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1313 ;; lets see if we're nested. find the most nested
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1314 ;; containing brace
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1315 (setq containing-sexp (car brace-state)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1316 brace-state (cdr brace-state)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1317 ;; 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
1318 (c-beginning-of-statement-1
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1319 (c-most-enclosing-brace brace-state))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1320 (setq bufpos (point))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1321 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1322 bufpos))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1323 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1324
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1325 (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
1326 ;; 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
1327 ;; `([ ])', `(< >)' 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
1328 ;; 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
1329 ;; 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
1330 ;; 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
1331 ;; 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
1332 ;; 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
1333 ;; 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
1334 ;; a special brace list).
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1335 (if c-special-brace-lists
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1336 (condition-case ()
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1337 (save-excursion
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1338 (let ((beg (point))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1339 end type)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1340 (c-forward-syntactic-ws)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1341 (if (eq (char-after) ?\()
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1342 (progn
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1343 (forward-char 1)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1344 (c-forward-syntactic-ws)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1345 (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
1346 (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
1347 (progn
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1348 (c-backward-syntactic-ws)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1349 (forward-char -1)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1350 (setq beg (if (eq (char-after) ?\()
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1351 (point)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1352 nil)))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1353 (if (and beg type)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1354 (if (and (c-safe (goto-char beg)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1355 (c-forward-sexp 1)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1356 (setq end (point))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1357 (= (char-before) ?\)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1358 (c-safe (goto-char beg)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1359 (forward-char 1)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1360 (c-forward-sexp 1)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1361 ;; Kludges needed to handle inner
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1362 ;; chars both with and without
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1363 ;; paren syntax.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1364 (or (/= (char-syntax (char-before)) ?\))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1365 (= (char-before) (cdr type)))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1366 (if (or (/= (char-syntax (char-before)) ?\))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1367 (= (progn
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1368 (c-forward-syntactic-ws)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1369 (point))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1370 (1- end)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1371 (cons (cons beg end) type))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1372 (cons (list beg) type)))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1373 (error nil))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1374
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1375 (defun c-looking-at-bos ()
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1376 ;; Returns nil if inside a statement or declaration.
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1377 (save-excursion
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1378 (c-backward-syntactic-ws)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1379 (or (bobp)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1380 (memq (char-before) '(?\; ?}))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1381 (and (eq (char-before) ?{)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1382 (not (and c-special-brace-lists
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1383 (progn (backward-char)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1384 (c-looking-at-special-brace-list))))))))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1385
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1386 (defun c-looking-at-inexpr-block (&optional lim)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1387 ;; Returns non-nil if we're looking at the beginning of a block
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1388 ;; 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
1389 ;; either 'inlambda, 'inexpr-statement or 'inexpr-class and the
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1390 ;; position of the beginning of the construct. LIM limits the
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1391 ;; backward search.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1392 (save-excursion
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1393 (or lim (setq lim (point-min)))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1394 (let ((block-follows (eq (char-after) ?{)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1395 ;; Look at the character after point only as a last resort when
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1396 ;; we can't disambiguate.
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1397 (if (and block-follows
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1398 (progn (c-backward-syntactic-ws) (> (point) lim))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1399 (eq (char-before) ?\()
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1400 (not (and c-special-brace-lists
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1401 (c-looking-at-special-brace-list))))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1402 (cons 'inexpr-statement (point))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1403 (let (res)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1404 (while (and (not res)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1405 (= (c-backward-token-1 1 t lim) 0)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1406 (>= (point) lim)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1407 (looking-at "(\\|\\w\\|\\s_\\|\\."))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1408 (setq res
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1409 (cond ((and block-follows
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1410 c-inexpr-class-key
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1411 (looking-at c-inexpr-class-key)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1412 (or (not (looking-at c-class-key))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1413 (let ((prev (point)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1414 (while (and (= (c-backward-token-1 1 t lim)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1415 0)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1416 (>= (point) lim)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1417 (eq (char-syntax (char-after))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1418 ?w))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1419 (setq prev (point)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1420 (goto-char prev)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1421 (not (c-looking-at-bos)))))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1422 (cons 'inexpr-class (point)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1423 ((and c-inexpr-block-key
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1424 (looking-at c-inexpr-block-key))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1425 (cons 'inexpr-statement (point)))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1426 ((and c-lambda-key
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1427 (looking-at c-lambda-key))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1428 (cons 'inlambda (point))))))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1429 res)))))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1430
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1431 (defun c-looking-at-inexpr-block-backward (&optional lim)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1432 ;; 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
1433 ;; block, otherwise the same as `c-looking-at-inexpr-block'.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1434 (save-excursion
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1435 (let ((lim (or lim (c-point 'bod))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1436 (c-safe
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1437 (c-backward-syntactic-ws lim)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1438 (if (eq (char-before) ?}) ; Recognize only a block currently.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1439 (progn
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1440 (c-forward-sexp -1)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1441 (if (>= (point) lim)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1442 (c-looking-at-inexpr-block lim))))))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1443
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1444 (defun c-on-identifier ()
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1445 ;; Returns non-nil if we're on or directly after an identifier.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1446 (if (or (memq (char-syntax (or (char-after) ? )) '(?w ?_))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1447 (memq (char-syntax (or (char-before) ? )) '(?w ?_)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1448 (save-excursion
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1449 (skip-syntax-backward "w_")
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1450 (not (looking-at c-keywords)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1451 (if (c-major-mode-is 'pike-mode)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1452 ;; Handle the `<operator> syntax in Pike.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1453 (save-excursion
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1454 (if (eq (char-after) ?\`) (forward-char))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1455 (skip-chars-backward "!%&*+\\-/<=>^|~")
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1456 (let ((pos (point)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1457 (cond ((memq (char-before) '(?\) ?\]))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1458 (c-safe (backward-char 2)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1459 ((memq (char-before) '(?\( ?\[))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1460 (c-safe (backward-char 1))))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1461 (if (not (looking-at "()\\|\\[]"))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1462 (goto-char pos)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1463 (and (eq (char-before) ?\`)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1464 (looking-at "[-!%&*+/<=>^|~]\\|()\\|\\[]"))))))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1465
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1466
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1467 (defun c-most-enclosing-brace (state)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1468 ;; return the bufpos of the most enclosing brace that hasn't been
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1469 ;; narrowed out by any enclosing class, or nil if none was found
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1470 (let (enclosingp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1471 (while (and state (not enclosingp))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1472 (setq enclosingp (car state)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1473 state (cdr state))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1474 (if (consp enclosingp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1475 (setq enclosingp nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1476 (if (> (point-min) enclosingp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1477 (setq enclosingp nil))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1478 (setq state nil)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1479 enclosingp))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1480
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1481 (defun c-least-enclosing-brace (state)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1482 ;; return the bufpos of the least (highest) enclosing brace that
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1483 ;; hasn't been narrowed out by any enclosing class, or nil if none
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1484 ;; was found.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1485 (c-most-enclosing-brace (nreverse state)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1486
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1487 (defun c-safe-position (bufpos state)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1488 ;; return the closest known safe position higher up than point
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1489 (let ((safepos nil))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1490 (while state
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1491 (setq safepos
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1492 (if (consp (car state))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1493 (cdr (car state))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1494 (car state)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1495 (if (< safepos bufpos)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1496 (setq state nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1497 (setq state (cdr state))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1498 safepos))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1499
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1500 (defun c-narrow-out-enclosing-class (state lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1501 ;; narrow the buffer so that the enclosing class is hidden
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1502 (setq state (c-whack-state (point) state))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1503 (let (inclass-p)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1504 (and state
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1505 (setq inclass-p (c-search-uplist-for-classkey state))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1506 (narrow-to-region
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1507 (progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1508 (goto-char (1+ (aref inclass-p 1)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1509 (skip-chars-forward " \t\n" lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1510 ;; if point is now left of the class opening brace, we're
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1511 ;; hosed, so try a different tact
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1512 (if (<= (point) (aref inclass-p 1))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1513 (progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1514 (goto-char (1+ (aref inclass-p 1)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1515 (c-forward-syntactic-ws lim)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1516 (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1517 ;; end point is the end of the current line
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1518 (progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1519 (goto-char lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1520 (c-point 'eol))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1521 ;; return the class vector
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1522 inclass-p))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1523
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1524
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1525 ;; This function implements the main decision tree for determining the
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1526 ;; syntactic analysis of the current line of code. Yes, it's huge and
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1527 ;; bloated!
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1528
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1529 (defun c-guess-basic-syntax ()
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1530 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1531 (save-restriction
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1532 (beginning-of-line)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1533 (let* ((indent-point (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1534 (case-fold-search nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1535 (fullstate (c-parse-state))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1536 (state fullstate)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1537 literal containing-sexp char-before-ip char-after-ip lim
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1538 syntax placeholder c-in-literal-cache inswitch-p
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1539 tmpsymbol keyword injava-inher special-brace-list
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1540 ;; narrow out any enclosing class or extern "C" block
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1541 (inclass-p (c-narrow-out-enclosing-class state indent-point))
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1542 inenclosing-p)
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1543 ;; check for meta top-level enclosing constructs, possible
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1544 ;; extern language definitions, possibly (in C++) namespace
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1545 ;; definitions.
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1546 (save-excursion
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1547 (save-restriction
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1548 (widen)
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1549 (if (and inclass-p
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1550 (progn
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1551 (goto-char (aref inclass-p 0))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1552 (looking-at (concat c-extra-toplevel-key "[^_]"))))
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1553 (let ((enclosing (match-string 1)))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1554 (cond
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1555 ((string-equal enclosing "extern")
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1556 (setq inenclosing-p 'extern))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1557 ((string-equal enclosing "namespace")
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1558 (setq inenclosing-p 'namespace))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1559 )))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1560 ;; get the buffer position of the most nested opening brace,
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1561 ;; if there is one, and it hasn't been narrowed out
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1562 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1563 (goto-char indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1564 (skip-chars-forward " \t}")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1565 (skip-chars-backward " \t")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1566 (while (and state
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1567 (not containing-sexp))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1568 (setq containing-sexp (car state)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1569 state (cdr state))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1570 (if (consp containing-sexp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1571 ;; if cdr == point, then containing sexp is the brace
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1572 ;; that opens the sexp we close
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1573 (if (= (cdr containing-sexp) (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1574 (setq containing-sexp (car containing-sexp))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1575 ;; otherwise, ignore this element
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1576 (setq containing-sexp nil))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1577 ;; ignore the bufpos if its been narrowed out by the
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1578 ;; containing class or does not contain the indent point
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1579 (if (or (<= containing-sexp (point-min))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1580 (>= containing-sexp indent-point))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1581 (setq containing-sexp nil)))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1582
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1583 ;; set the limit on the farthest back we need to search
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1584 (setq lim (or containing-sexp
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1585 (if (consp (car fullstate))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1586 (cdr (car fullstate))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1587 nil)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1588 (point-min)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1589
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1590 ;; cache char before and after indent point, and move point to
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1591 ;; the most likely position to perform the majority of tests
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1592 (goto-char indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1593 (skip-chars-forward " \t")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1594 (setq char-after-ip (char-after))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1595 (c-backward-syntactic-ws lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1596 (setq char-before-ip (char-before))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1597 (goto-char indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1598 (skip-chars-forward " \t")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1599
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1600 ;; are we in a literal?
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1601 (setq literal (c-in-literal lim))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1602
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1603 ;; now figure out syntactic qualities of the current line
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1604 (cond
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1605 ;; CASE 1: in a string.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1606 ((memq literal '(string))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1607 (c-add-syntax 'string (c-point 'bopl)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1608 ;; CASE 2: in a C or C++ style comment.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1609 ((memq literal '(c c++))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1610 (c-add-syntax literal (car (c-literal-limits lim))))
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1611 ;; CASE 3: in a cpp preprocessor macro continuation.
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1612 ((and (eq literal 'pound)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1613 (/= (save-excursion
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1614 (c-beginning-of-macro lim)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1615 (setq placeholder (point)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1616 (c-point 'boi)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1617 (c-add-syntax 'cpp-macro-cont placeholder))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1618 ;; CASE 4: In-expression statement.
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1619 ((and (or c-inexpr-class-key c-inexpr-block-key c-lambda-key)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1620 (setq placeholder (c-looking-at-inexpr-block)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1621 (setq tmpsymbol (assq (car placeholder)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1622 '((inexpr-class . class-open)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1623 (inexpr-statement . block-open))))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1624 (if tmpsymbol
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1625 ;; 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
1626 (setq tmpsymbol (cdr tmpsymbol))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1627 ;; 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
1628 ;; 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
1629 ;; opener.
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1630 (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
1631 'inline-open
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1632 'lambda-intro-cont)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1633 (goto-char (cdr placeholder))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1634 (back-to-indentation)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1635 (c-add-syntax tmpsymbol (point))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1636 (unless (eq (point) (cdr placeholder))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1637 (c-add-syntax (car placeholder))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1638 ;; CASE 5: Line is at top level.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1639 ((null containing-sexp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1640 (cond
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1641 ;; 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
1642 ;; or inline-inclass method opening brace
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1643 ((setq special-brace-list
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1644 (or (and c-special-brace-lists
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1645 (c-looking-at-special-brace-list))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1646 (eq char-after-ip ?{)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1647 (cond
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1648 ;; CASE 5A.1: extern language or namespace construct
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1649 ((save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1650 (goto-char indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1651 (skip-chars-forward " \t")
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1652 (and (c-safe (progn (c-backward-sexp 2) t))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1653 (looking-at (concat c-extra-toplevel-key "[^_]"))
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1654 (setq keyword (match-string 1)
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1655 placeholder (point))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1656 (or (and (string-equal keyword "namespace")
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1657 (setq tmpsymbol 'namespace-open))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1658 (and (string-equal keyword "extern")
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1659 (progn
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1660 (c-forward-sexp 1)
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1661 (c-forward-syntactic-ws)
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1662 (eq (char-after) ?\"))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1663 (setq tmpsymbol 'extern-lang-open)))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1664 ))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1665 (goto-char placeholder)
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1666 (c-add-syntax tmpsymbol (c-point 'boi)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1667 ;; CASE 5A.2: we are looking at a class opening brace
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1668 ((save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1669 (goto-char indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1670 (skip-chars-forward " \t{")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1671 ;; TBD: watch out! there could be a bogus
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1672 ;; c-state-cache in place when we get here. we have
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1673 ;; to go through much chicanery to ignore the cache.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1674 ;; But of course, there may not be! BLECH! BOGUS!
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1675 (let ((decl
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1676 (let ((c-state-cache nil))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1677 (c-search-uplist-for-classkey (c-parse-state))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1678 )))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1679 (and decl
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1680 (setq placeholder (aref decl 0)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1681 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1682 (c-add-syntax 'class-open placeholder))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1683 ;; CASE 5A.3: brace list open
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1684 ((save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1685 (c-beginning-of-statement-1 lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1686 ;; c-b-o-s could have left us at point-min
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1687 (and (bobp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1688 (c-forward-syntactic-ws indent-point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1689 (if (looking-at "typedef[^_]")
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1690 (progn (c-forward-sexp 1)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1691 (c-forward-syntactic-ws indent-point)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1692 (setq placeholder (c-point 'boi))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1693 (or (consp special-brace-list)
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1694 (and (or (save-excursion
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1695 (goto-char indent-point)
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1696 (setq tmpsymbol nil)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1697 (while (and (> (point) placeholder)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1698 (= (c-backward-token-1 1 t) 0)
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1699 (/= (char-after) ?=))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1700 (if (and (not tmpsymbol)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1701 (looking-at "new\\>[^_]"))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1702 (setq tmpsymbol 'topmost-intro-cont)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1703 (eq (char-after) ?=))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1704 (looking-at "enum[ \t\n]+"))
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
1705 (save-excursion
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1706 (while (and (< (point) indent-point)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1707 (= (c-forward-token-1 1 t) 0)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1708 (not (memq (char-after) '(?\; ?\()))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1709 (not (memq (char-after) '(?\; ?\()))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1710 ))))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1711 (if (and (c-major-mode-is 'java-mode)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1712 (eq tmpsymbol 'topmost-intro-cont))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1713 ;; 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
1714 ;; belongs to a "new Foo[]" initialization list,
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1715 ;; which means the brace list is part of an
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1716 ;; expression and not a top level definition. We
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1717 ;; therefore treat it as any topmost continuation
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1718 ;; even though the semantically correct symbol still
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1719 ;; is brace-list-open, on the same grounds as in
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1720 ;; case 10B.2.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1721 (progn
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1722 (c-beginning-of-statement-1 lim)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1723 (c-forward-syntactic-ws)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1724 (c-add-syntax 'topmost-intro-cont (c-point 'boi)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
1725 (c-add-syntax 'brace-list-open placeholder)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1726 ;; CASE 5A.4: inline defun open
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1727 ((and inclass-p (not inenclosing-p))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1728 (c-add-syntax 'inline-open)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1729 (c-add-class-syntax 'inclass inclass-p))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1730 ;; CASE 5A.5: ordinary defun open
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1731 (t
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1732 (goto-char placeholder)
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
1733 (if inclass-p
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
1734 (c-add-syntax 'defun-open (c-point 'boi))
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
1735 (c-add-syntax 'defun-open (c-point 'bol)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1736 )))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1737 ;; CASE 5B: first K&R arg decl or member init
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1738 ((c-just-after-func-arglist-p)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1739 (cond
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1740 ;; CASE 5B.1: a member init
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1741 ((or (eq char-before-ip ?:)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1742 (eq char-after-ip ?:))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1743 ;; this line should be indented relative to the beginning
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1744 ;; of indentation for the topmost-intro line that contains
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1745 ;; the prototype's open paren
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1746 ;; TBD: is the following redundant?
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1747 (if (eq char-before-ip ?:)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1748 (forward-char -1))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1749 (c-backward-syntactic-ws lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1750 ;; TBD: is the preceding redundant?
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1751 (if (eq (char-before) ?:)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1752 (progn (forward-char -1)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1753 (c-backward-syntactic-ws lim)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1754 (if (eq (char-before) ?\))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1755 (c-backward-sexp 1))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1756 (setq placeholder (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1757 (save-excursion
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1758 (and (c-safe (c-backward-sexp 1) t)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1759 (looking-at "throw[^_]")
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1760 (c-safe (c-backward-sexp 1) t)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1761 (setq placeholder (point))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1762 (goto-char placeholder)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1763 (c-add-syntax 'member-init-intro (c-point 'boi))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1764 ;; we don't need to add any class offset since this
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1765 ;; should be relative to the ctor's indentation
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1766 )
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1767 ;; CASE 5B.2: K&R arg decl intro
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1768 (c-recognize-knr-p
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1769 (c-add-syntax 'knr-argdecl-intro (c-point 'boi))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1770 (if inclass-p (c-add-class-syntax 'inclass inclass-p)))
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1771 ;; CASE 5B.3: Inside a member init list.
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1772 ((c-beginning-of-member-init-list lim)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1773 (c-forward-syntactic-ws)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1774 (c-add-syntax 'member-init-cont (point)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1775 ;; CASE 5B.4: Nether region after a C++ or Java func
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1776 ;; decl, which could include a `throws' declaration.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1777 (t
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1778 (c-beginning-of-statement-1 lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1779 (c-add-syntax 'func-decl-cont (c-point 'boi))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1780 )))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1781 ;; CASE 5C: inheritance line. could be first inheritance
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1782 ;; line, or continuation of a multiple inheritance
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1783 ((or (and c-baseclass-key
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1784 (progn
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1785 (when (eq char-after-ip ?,)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1786 (skip-chars-forward " \t")
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1787 (forward-char))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1788 (looking-at c-baseclass-key)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1789 (and (or (eq char-before-ip ?:)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1790 ;; watch out for scope operator
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1791 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1792 (and (eq char-after-ip ?:)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1793 (c-safe (progn (forward-char 1) t))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1794 (not (eq (char-after) ?:))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1795 )))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1796 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1797 (c-backward-syntactic-ws lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1798 (if (eq char-before-ip ?:)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1799 (progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1800 (forward-char -1)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1801 (c-backward-syntactic-ws lim)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1802 (back-to-indentation)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1803 (looking-at c-class-key)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1804 ;; for Java
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1805 (and (c-major-mode-is 'java-mode)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1806 (let ((fence (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1807 (c-beginning-of-statement-1 lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1808 (point)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1809 cont done)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1810 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1811 (while (not done)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1812 (cond ((looking-at c-Java-special-key)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1813 (setq injava-inher (cons cont (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1814 done t))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1815 ((or (not (c-safe (c-forward-sexp -1) t))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1816 (<= (point) fence))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1817 (setq done t))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1818 )
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1819 (setq cont t)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1820 injava-inher)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1821 (not (c-crosses-statement-barrier-p (cdr injava-inher)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1822 (point)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1823 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1824 (cond
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1825 ;; CASE 5C.1: non-hanging colon on an inher intro
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1826 ((eq char-after-ip ?:)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1827 (c-backward-syntactic-ws lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1828 (c-add-syntax 'inher-intro (c-point 'boi))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1829 ;; don't add inclass symbol since relative point already
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1830 ;; contains any class offset
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1831 )
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1832 ;; CASE 5C.2: hanging colon on an inher intro
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1833 ((eq char-before-ip ?:)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1834 (c-add-syntax 'inher-intro (c-point 'boi))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1835 (if inclass-p (c-add-class-syntax 'inclass inclass-p)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1836 ;; CASE 5C.3: in a Java implements/extends
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1837 (injava-inher
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1838 (let ((where (cdr injava-inher))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1839 (cont (car injava-inher)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1840 (goto-char where)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1841 (cond ((looking-at "throws[ \t\n]")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1842 (c-add-syntax 'func-decl-cont
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1843 (progn (c-beginning-of-statement-1 lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1844 (c-point 'boi))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1845 (cont (c-add-syntax 'inher-cont where))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1846 (t (c-add-syntax 'inher-intro
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1847 (progn (goto-char (cdr injava-inher))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1848 (c-beginning-of-statement-1 lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1849 (point))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1850 )))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1851 ;; CASE 5C.4: a continued inheritance line
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1852 (t
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1853 (c-beginning-of-inheritance-list lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1854 (c-add-syntax 'inher-cont (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1855 ;; don't add inclass symbol since relative point already
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1856 ;; contains any class offset
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1857 )))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1858 ;; CASE 5D: this could be a top-level compound statement, a
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1859 ;; member init list continuation, or a template argument
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1860 ;; list continuation.
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1861 ((c-with-syntax-table (if (c-major-mode-is 'c++-mode)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1862 c++-template-syntax-table
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1863 (syntax-table))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1864 (save-excursion
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1865 (while (and (= (c-backward-token-1 1 t lim) 0)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1866 (not (looking-at "[;{<,]"))))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1867 (eq (char-after) ?,)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1868 (goto-char indent-point)
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1869 (c-beginning-of-member-init-list lim)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1870 (cond
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1871 ;; CASE 5D.1: hanging member init colon, but watch out
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1872 ;; for bogus matches on access specifiers inside classes.
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1873 ((and (save-excursion
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1874 (setq placeholder (point))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1875 (c-backward-token-1 1 t lim)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1876 (and (eq (char-after) ?:)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1877 (not (eq (char-before) ?:))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1878 (save-excursion
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1879 (goto-char placeholder)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1880 (back-to-indentation)
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1881 (or
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1882 (/= (car (save-excursion
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1883 (parse-partial-sexp (point) placeholder)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1884 0)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1885 (and
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1886 (if c-access-key (not (looking-at c-access-key)) t)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1887 (not (looking-at c-class-key))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1888 (if c-bitfield-key (not (looking-at c-bitfield-key)) t))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1889 )))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1890 (goto-char placeholder)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1891 (c-forward-syntactic-ws)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1892 (c-add-syntax 'member-init-cont (point))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1893 ;; we do not need to add class offset since relative
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1894 ;; point is the member init above us
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1895 )
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1896 ;; CASE 5D.2: non-hanging member init colon
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1897 ((progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1898 (c-forward-syntactic-ws indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1899 (eq (char-after) ?:))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1900 (skip-chars-forward " \t:")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1901 (c-add-syntax 'member-init-cont (point)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1902 ;; CASE 5D.3: perhaps a multiple inheritance line?
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1903 ((save-excursion
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1904 (c-beginning-of-statement-1 lim)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1905 (setq placeholder (point))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1906 (looking-at c-inher-key))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1907 (goto-char placeholder)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1908 (c-add-syntax 'inher-cont (c-point 'boi)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1909 ;; CASE 5D.4: perhaps a template list continuation?
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1910 ((save-excursion
19301
c4d7dd15f7d5 (c-guess-basic-syntax): CASE 5D.4: template argument continuation
Richard M. Stallman <rms@gnu.org>
parents: 19251
diff changeset
1911 (goto-char indent-point)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1912 (skip-chars-backward "^<" lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1913 ;; not sure if this is the right test, but it should
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1914 ;; be fast and mostly accurate.
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1915 (setq placeholder (point))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1916 (and (eq (char-before) ?<)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1917 (not (c-in-literal lim))))
19301
c4d7dd15f7d5 (c-guess-basic-syntax): CASE 5D.4: template argument continuation
Richard M. Stallman <rms@gnu.org>
parents: 19251
diff changeset
1918 ;; we can probably indent it just like an arglist-cont
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1919 (goto-char placeholder)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1920 (c-beginning-of-statement-1 lim)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
1921 (c-add-syntax 'template-args-cont (c-point 'boi)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1922 ;; CASE 5D.5: perhaps a top-level statement-cont
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1923 (t
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1924 (c-beginning-of-statement-1 lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1925 ;; skip over any access-specifiers
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1926 (and inclass-p c-access-key
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1927 (while (looking-at c-access-key)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1928 (forward-line 1)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1929 ;; skip over comments, whitespace
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1930 (c-forward-syntactic-ws indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1931 (c-add-syntax 'statement-cont (c-point 'boi)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1932 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1933 ;; CASE 5E: we are looking at a access specifier
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1934 ((and inclass-p
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1935 c-access-key
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1936 (looking-at c-access-key))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1937 (c-add-syntax 'access-label (c-point 'bonl))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1938 (c-add-class-syntax 'inclass inclass-p))
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
1939 ;; CASE 5F: extern-lang-close or namespace-close?
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1940 ((and inenclosing-p
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1941 (eq char-after-ip ?}))
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1942 (setq tmpsymbol (if (eq inenclosing-p 'extern)
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1943 'extern-lang-close
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1944 'namespace-close))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
1945 (c-add-syntax tmpsymbol (aref inclass-p 0)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1946 ;; CASE 5G: we are looking at the brace which closes the
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1947 ;; enclosing nested class decl
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1948 ((and inclass-p
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1949 (eq char-after-ip ?})
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1950 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1951 (save-restriction
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1952 (widen)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1953 (forward-char 1)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1954 (and (c-safe (progn (c-backward-sexp 1) t))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1955 (= (point) (aref inclass-p 1))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1956 ))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1957 (c-add-class-syntax 'class-close inclass-p))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1958 ;; CASE 5H: we could be looking at subsequent knr-argdecls
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1959 ((and c-recognize-knr-p
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1960 ;; here we essentially use the hack that is used in
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1961 ;; Emacs' c-mode.el to limit how far back we should
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1962 ;; look. The assumption is made that argdecls are
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1963 ;; indented at least one space and that function
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1964 ;; headers are not indented.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1965 (let ((limit (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1966 (re-search-backward "^[^ \^L\t\n#]" nil 'move)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1967 (point))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1968 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1969 (c-backward-syntactic-ws limit)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1970 (setq placeholder (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1971 (while (and (memq (char-before) '(?\; ?,))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1972 (> (point) limit))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1973 (beginning-of-line)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1974 (setq placeholder (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1975 (c-backward-syntactic-ws limit))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1976 (and (eq (char-before) ?\))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1977 (or (not c-method-key)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1978 (progn
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1979 (c-forward-sexp -1)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1980 (forward-char -1)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1981 (c-backward-syntactic-ws)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1982 (not (or (memq (char-before) '(?- ?+))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1983 ;; or a class category
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1984 (progn
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
1985 (c-forward-sexp -2)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1986 (looking-at c-class-key))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1987 )))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1988 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1989 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1990 (c-beginning-of-statement-1)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1991 (not (looking-at "typedef[ \t\n]+"))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1992 (goto-char placeholder)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1993 (c-add-syntax 'knr-argdecl (c-point 'boi)))
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1994 ;; CASE 5I: ObjC method definition.
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1995 ((and c-method-key
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1996 (looking-at c-method-key))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1997 (c-add-syntax 'objc-method-intro (c-point 'boi)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
1998 ;; CASE 5J: we are at the topmost level, make sure we skip
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
1999 ;; back past any access specifiers
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2000 ((progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2001 (c-backward-syntactic-ws lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2002 (while (and inclass-p
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2003 c-access-key
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2004 (not (bobp))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2005 (save-excursion
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2006 (c-safe (progn (c-backward-sexp 1) t))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2007 (looking-at c-access-key)))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2008 (c-backward-sexp 1)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2009 (c-backward-syntactic-ws lim))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2010 (or (bobp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2011 (memq (char-before) '(?\; ?\}))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2012 ;; real beginning-of-line could be narrowed out due to
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2013 ;; enclosure in a class block
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2014 (save-restriction
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2015 (widen)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2016 (c-add-syntax 'topmost-intro (c-point 'bol))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2017 (if inclass-p
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2018 (progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2019 (goto-char (aref inclass-p 1))
19251
6a7d40ec4b29 (c-beginning-of-statement-1): When checking for bare semi, don't match
Richard M. Stallman <rms@gnu.org>
parents: 18844
diff changeset
2020 (or (= (point) (c-point 'boi))
6a7d40ec4b29 (c-beginning-of-statement-1): When checking for bare semi, don't match
Richard M. Stallman <rms@gnu.org>
parents: 18844
diff changeset
2021 (goto-char (aref inclass-p 0)))
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
2022 (cond
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
2023 ((eq inenclosing-p 'extern)
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
2024 (c-add-syntax 'inextern-lang (c-point 'boi)))
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
2025 ((eq inenclosing-p 'namespace)
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
2026 (c-add-syntax 'innamespace (c-point 'boi)))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2027 (t (c-add-class-syntax 'inclass inclass-p)))
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
2028 ))
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
2029 ))
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2030 ;; CASE 5K: we are at an ObjC or Java method definition
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2031 ;; continuation line.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2032 ((and c-method-key
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2033 (progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2034 (c-beginning-of-statement-1 lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2035 (beginning-of-line)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2036 (looking-at c-method-key)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2037 (c-add-syntax 'objc-method-args-cont (point)))
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2038 ;; 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
2039 ;; arglist that begins on the previous line.
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2040 ((eq (char-before) ?<)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2041 (c-beginning-of-statement-1 lim)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2042 (c-forward-syntactic-ws)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2043 (c-add-syntax 'template-args-cont (c-point 'boi)))
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2044 ;; CASE 5M: we are at a topmost continuation line
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2045 (t
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2046 (c-beginning-of-statement-1 lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2047 (c-forward-syntactic-ws)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2048 (c-add-syntax 'topmost-intro-cont (c-point 'boi)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2049 )) ; end CASE 5
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2050 ;; (CASE 6 has been removed.)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2051 ;; CASE 7: line is an expression, not a statement. Most
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2052 ;; likely we are either in a function prototype or a function
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2053 ;; call argument list
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2054 ((not (or (and c-special-brace-lists
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2055 (save-excursion
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2056 (goto-char containing-sexp)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2057 (c-looking-at-special-brace-list)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2058 (eq (char-after containing-sexp) ?{)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2059 (c-backward-syntactic-ws containing-sexp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2060 (cond
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2061 ;; CASE 7A: we are looking at the arglist closing paren
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2062 ((and (or (c-major-mode-is 'pike-mode)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2063 ;; Don't check this in Pike since it allows a
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2064 ;; comma after the last arg.
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2065 (not (eq char-before-ip ?,)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2066 (memq char-after-ip '(?\) ?\])))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2067 (goto-char containing-sexp)
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2068 (setq placeholder (c-point 'boi))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2069 (when (and (c-safe (backward-up-list 1) t)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2070 (> (point) placeholder))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2071 (forward-char)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2072 (skip-chars-forward " \t")
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2073 (setq placeholder (point)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2074 (c-add-syntax 'arglist-close placeholder))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2075 ;; CASE 7B: Looking at the opening brace of an
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2076 ;; in-expression block or brace list.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2077 ((eq char-after-ip ?{)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2078 (goto-char indent-point)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2079 (setq placeholder (c-point 'boi))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2080 (goto-char containing-sexp)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2081 (if (c-inside-bracelist-p placeholder
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2082 (cons containing-sexp state))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2083 (progn
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2084 (c-add-syntax 'brace-list-open (c-point 'boi))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2085 (c-add-syntax 'inexpr-class))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2086 (c-add-syntax 'block-open (c-point 'boi))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2087 (c-add-syntax 'inexpr-statement)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2088 ;; 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
2089 ;; argument list. Use arglist-close if we're actually
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2090 ;; looking at a close paren or bracket.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2091 ((memq char-before-ip '(?\( ?\[))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2092 (goto-char containing-sexp)
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2093 (setq placeholder (c-point 'boi))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2094 (when (and (c-safe (backward-up-list 1) t)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2095 (> (point) placeholder))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2096 (forward-char)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2097 (skip-chars-forward " \t")
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2098 (setq placeholder (point)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2099 (c-add-syntax 'arglist-intro placeholder))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2100 ;; CASE 7D: we are inside a conditional test clause. treat
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2101 ;; these things as statements
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2102 ((save-excursion
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
2103 (goto-char containing-sexp)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2104 (and (c-safe (progn (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
2105 (looking-at "\\<for\\>[^_]")))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2106 (goto-char (1+ containing-sexp))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2107 (c-forward-syntactic-ws indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2108 (c-beginning-of-statement-1 containing-sexp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2109 (if (eq char-before-ip ?\;)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2110 (c-add-syntax 'statement (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2111 (c-add-syntax 'statement-cont (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2112 ))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2113 ;; CASE 7E: maybe a continued method call. This is the case
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2114 ;; when we are inside a [] bracketed exp, and what precede
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2115 ;; the opening bracket is not an identifier.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2116 ((and c-method-key
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2117 (eq (char-after containing-sexp) ?\[)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2118 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2119 (goto-char (1- containing-sexp))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2120 (c-backward-syntactic-ws (c-point 'bod))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2121 (if (not (looking-at c-symbol-key))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2122 (c-add-syntax 'objc-method-call-cont containing-sexp))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2123 )))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2124 ;; CASE 7F: we are looking at an arglist continuation line,
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2125 ;; but the preceding argument is on the same line as the
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2126 ;; opening paren. This case includes multi-line
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2127 ;; mathematical paren groupings, but we could be on a
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2128 ;; for-list continuation line
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2129 ((save-excursion
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2130 (goto-char (1+ containing-sexp))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2131 (skip-chars-forward " \t")
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2132 (not (eolp)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2133 (goto-char containing-sexp)
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2134 (setq placeholder (c-point 'boi))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2135 (when (and (c-safe (backward-up-list 1) t)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2136 (> (point) placeholder))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2137 (forward-char)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2138 (skip-chars-forward " \t")
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2139 (setq placeholder (point)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2140 (c-add-syntax 'arglist-cont-nonempty placeholder))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2141 ;; CASE 7G: we are looking at just a normal arglist
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2142 ;; continuation line
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2143 (t (c-beginning-of-statement-1 containing-sexp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2144 (forward-char 1)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2145 (c-forward-syntactic-ws indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2146 (c-add-syntax 'arglist-cont (c-point 'boi)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2147 ))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2148 ;; CASE 8: func-local multi-inheritance line
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2149 ((and c-baseclass-key
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2150 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2151 (goto-char indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2152 (skip-chars-forward " \t")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2153 (looking-at c-baseclass-key)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2154 (goto-char indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2155 (skip-chars-forward " \t")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2156 (cond
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2157 ;; CASE 8A: non-hanging colon on an inher intro
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2158 ((eq char-after-ip ?:)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2159 (c-backward-syntactic-ws lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2160 (c-add-syntax 'inher-intro (c-point 'boi)))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2161 ;; CASE 8B: hanging colon on an inher intro
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2162 ((eq char-before-ip ?:)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2163 (c-add-syntax 'inher-intro (c-point 'boi)))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2164 ;; CASE 8C: a continued inheritance line
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2165 (t
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2166 (c-beginning-of-inheritance-list lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2167 (c-add-syntax 'inher-cont (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2168 )))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2169 ;; CASE 9: we are inside a brace-list
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2170 ((setq special-brace-list
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2171 (or (and c-special-brace-lists
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2172 (save-excursion
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2173 (goto-char containing-sexp)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2174 (c-looking-at-special-brace-list)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2175 (c-inside-bracelist-p containing-sexp state)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2176 (cond
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2177 ;; 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
2178 ((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
2179 (save-excursion
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2180 (goto-char containing-sexp)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2181 (eq (char-after) ?\())
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2182 (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
2183 (goto-char (car (car special-brace-list)))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2184 (skip-chars-backward " \t")
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2185 (if (and (bolp)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2186 (assoc 'statement-cont
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2187 (setq placeholder (c-guess-basic-syntax))))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2188 (setq syntax placeholder)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2189 (c-beginning-of-statement-1 lim)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2190 (c-forward-token-1 0)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2191 (if (looking-at "typedef\\>") (c-forward-token-1 1))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2192 (c-add-syntax 'brace-list-open (c-point 'boi))))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2193 ;; CASE 9B: brace-list-close brace
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2194 ((if (consp special-brace-list)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2195 ;; Check special brace list closer.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2196 (progn
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2197 (goto-char (car (car special-brace-list)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2198 (save-excursion
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2199 (goto-char indent-point)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2200 (back-to-indentation)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2201 (or
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2202 ;; 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
2203 (and (eq (char-after) ?\))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2204 (eq (1+ (point)) (cdr (car special-brace-list))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2205 ;; We were before the special close char.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2206 (and (eq (char-after) (cdr (cdr special-brace-list)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2207 (= (c-forward-token-1) 0)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2208 (eq (1+ (point)) (cdr (car special-brace-list)))))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2209 ;; Normal brace list check.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2210 (and (eq char-after-ip ?})
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2211 (c-safe (progn (forward-char 1)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2212 (c-backward-sexp 1)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2213 t))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2214 (= (point) containing-sexp)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2215 (c-add-syntax 'brace-list-close (c-point 'boi)))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2216 (t
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2217 ;; 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
2218 ;; token following the opening brace
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2219 (if (consp special-brace-list)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2220 (progn
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2221 (goto-char (car (car special-brace-list)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2222 (c-forward-token-1 1 nil indent-point))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2223 (goto-char containing-sexp))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2224 (forward-char)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2225 (let ((start (point)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2226 (c-forward-syntactic-ws indent-point)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2227 (goto-char (max start (c-point 'bol))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2228 (skip-chars-forward " \t\n\r" indent-point)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2229 (cond
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2230 ;; 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
2231 ((= (point) indent-point)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2232 (goto-char containing-sexp)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2233 (c-add-syntax 'brace-list-intro (c-point 'boi))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2234 ) ; end CASE 9C
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2235 ;; 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
2236 ;; brace-entry-open
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2237 (t (if (or (eq char-after-ip ?{)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2238 (and c-special-brace-lists
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2239 (save-excursion
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2240 (goto-char indent-point)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2241 (c-forward-syntactic-ws (c-point 'eol))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2242 (c-looking-at-special-brace-list (point)))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2243 (c-add-syntax 'brace-entry-open (point))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2244 (c-add-syntax 'brace-list-entry (point))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2245 )) ; end CASE 9D
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2246 )))) ; end CASE 9
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2247 ;; CASE 10: A continued statement
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2248 ((and (not (memq char-before-ip '(?\; ?:)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2249 (or (not (eq char-before-ip ?}))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2250 (c-looking-at-inexpr-block-backward containing-sexp))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2251 (> (point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2252 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2253 (c-beginning-of-statement-1 containing-sexp)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2254 (c-forward-syntactic-ws)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2255 (setq placeholder (point))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2256 (/= placeholder containing-sexp))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2257 (goto-char indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2258 (skip-chars-forward " \t")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2259 (let ((after-cond-placeholder
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2260 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2261 (goto-char placeholder)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2262 (if (and c-conditional-key (looking-at c-conditional-key))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2263 (progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2264 (c-safe (c-skip-conditional))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2265 (c-forward-syntactic-ws)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2266 (if (eq (char-after) ?\;)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2267 (progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2268 (forward-char 1)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2269 (c-forward-syntactic-ws)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2270 (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2271 nil))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2272 (cond
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2273 ;; CASE 10A: substatement
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2274 ((and after-cond-placeholder
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2275 (>= after-cond-placeholder indent-point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2276 (goto-char placeholder)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2277 (if (eq char-after-ip ?{)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2278 (c-add-syntax 'substatement-open (c-point 'boi))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2279 (c-add-syntax 'substatement (c-point 'boi))))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2280 ;; CASE 10B: open braces for class or brace-lists
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2281 ((setq special-brace-list
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2282 (or (and c-special-brace-lists
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2283 (c-looking-at-special-brace-list))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2284 (eq char-after-ip ?{)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2285 (cond
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2286 ;; CASE 10B.1: class-open
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2287 ((save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2288 (goto-char indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2289 (skip-chars-forward " \t{")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2290 (let ((decl (c-search-uplist-for-classkey (c-parse-state))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2291 (and decl
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2292 (setq placeholder (aref decl 0)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2293 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2294 (c-add-syntax 'class-open placeholder))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2295 ;; CASE 10B.2: brace-list-open
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2296 ((or (consp special-brace-list)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2297 (save-excursion
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2298 (goto-char placeholder)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2299 (looking-at "\\<enum\\>"))
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
2300 (save-excursion
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
2301 (goto-char indent-point)
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
2302 (while (and (> (point) placeholder)
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
2303 (= (c-backward-token-1 1 t) 0)
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
2304 (/= (char-after) ?=)))
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
2305 (eq (char-after) ?=)))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2306 ;; The most semantically accurate symbol here is
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2307 ;; brace-list-open, but we report it simply as a
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2308 ;; statement-cont. The reason is that one normally
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2309 ;; adjusts brace-list-open for brace lists as
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2310 ;; top-level constructs, and brace lists inside
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2311 ;; statements is a completely different context.
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2312 (goto-char indent-point)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2313 (c-beginning-of-closest-statement)
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2314 (c-add-syntax 'statement-cont (c-point 'boi)))
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2315 ;; CASE 10B.3: The body of a function declared inside a
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2316 ;; normal block. This can only occur in Pike.
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2317 ((and (c-major-mode-is 'pike-mode)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2318 (progn
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2319 (goto-char indent-point)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2320 (not (c-looking-at-bos))))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2321 (c-beginning-of-closest-statement)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2322 (c-add-syntax 'defun-open (c-point 'boi)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2323 ;; CASE 10B.4: catch-all for unknown construct.
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2324 (t
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2325 ;; Can and should I add an extensibility hook here?
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2326 ;; Something like c-recognize-hook so support for
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2327 ;; unknown constructs could be added. It's probably a
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2328 ;; losing proposition, so I dunno.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2329 (goto-char placeholder)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2330 (c-add-syntax 'statement-cont (c-point 'boi))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2331 (c-add-syntax 'block-open))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2332 ))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2333 ;; CASE 10C: iostream insertion or extraction operator
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2334 ((looking-at "<<\\|>>")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2335 (goto-char placeholder)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2336 (and after-cond-placeholder
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2337 (goto-char after-cond-placeholder))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2338 (while (and (re-search-forward "<<\\|>>" indent-point 'move)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2339 (c-in-literal placeholder)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2340 ;; if we ended up at indent-point, then the first
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2341 ;; streamop is on a separate line. Indent the line like
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2342 ;; a statement-cont instead
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2343 (if (/= (point) indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2344 (c-add-syntax 'stream-op (c-point 'boi))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2345 (c-backward-syntactic-ws lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2346 (c-add-syntax 'statement-cont (c-point 'boi))))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2347 ;; CASE 10D: continued statement. find the accurate
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2348 ;; beginning of statement or substatement
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2349 (t
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2350 (c-beginning-of-statement-1 after-cond-placeholder)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2351 ;; KLUDGE ALERT! c-beginning-of-statement-1 can leave
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2352 ;; us before the lim we're passing in. It should be
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2353 ;; fixed, but I'm worried about side-effects at this
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2354 ;; late date. Fix for v5.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2355 (goto-char (or (and after-cond-placeholder
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2356 (max after-cond-placeholder (point)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2357 (point)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2358 (c-add-syntax 'statement-cont (point)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2359 )))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2360 ;; CASE 11: an else clause?
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2361 ((looking-at "\\<else\\>[^_]")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2362 (c-backward-to-start-of-if containing-sexp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2363 (c-add-syntax 'else-clause (c-point 'boi)))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2364 ;; CASE 12: Statement. But what kind? Lets see if its a
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2365 ;; while closure of a do/while construct
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2366 ((progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2367 (goto-char indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2368 (skip-chars-forward " \t")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2369 (and (looking-at "while\\b[^_]")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2370 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2371 (c-backward-to-start-of-do containing-sexp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2372 (setq placeholder (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2373 (looking-at "do\\b[^_]"))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2374 ))
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2375 (goto-char placeholder)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2376 (c-add-syntax 'do-while-closure (c-point 'boi)))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2377 ;; CASE 13: A catch or finally clause? This case is simpler
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2378 ;; than if-else and do-while, because a block is required
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2379 ;; after every try, catch and finally.
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2380 ((save-excursion
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2381 (and (cond ((c-major-mode-is 'c++-mode)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2382 (looking-at "\\<catch\\>[^_]"))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2383 ((c-major-mode-is 'java-mode)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2384 (looking-at "\\<\\(catch\\|finally\\)\\>[^_]")))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2385 (c-safe (c-backward-sexp) t)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2386 (eq (char-after) ?{)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2387 (c-safe (c-backward-sexp) t)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2388 (if (eq (char-after) ?\()
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2389 (c-safe (c-backward-sexp) t)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2390 t)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2391 (looking-at "\\<\\(try\\|catch\\)\\>[^_]")
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2392 (setq placeholder (c-point 'boi))))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2393 (c-add-syntax 'catch-clause placeholder))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2394 ;; CASE 14: A case or default label
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2395 ((looking-at c-switch-label-key)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2396 (goto-char containing-sexp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2397 ;; check for hanging braces
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2398 (if (/= (point) (c-point 'boi))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2399 (c-forward-sexp -1))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2400 (c-add-syntax 'case-label (c-point 'boi)))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2401 ;; CASE 15: any other label
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2402 ((looking-at c-label-key)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2403 (goto-char containing-sexp)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2404 ;; check for hanging braces
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2405 (if (/= (point) (c-point 'boi))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2406 (c-forward-sexp -1))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2407 (c-add-syntax 'label (c-point 'boi)))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2408 ;; CASE 16: block close brace, possibly closing the defun or
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2409 ;; the class
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2410 ((eq char-after-ip ?})
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2411 (let* ((lim (c-safe-position containing-sexp fullstate))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2412 (relpos (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2413 (goto-char containing-sexp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2414 (if (/= (point) (c-point 'boi))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2415 (c-beginning-of-statement-1 lim))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2416 (c-point 'boi))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2417 (cond
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2418 ;; CASE 16A: closing a lambda defun or an in-expression
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2419 ;; block?
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2420 ((save-excursion
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2421 (goto-char containing-sexp)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2422 (setq placeholder (c-looking-at-inexpr-block)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2423 (setq tmpsymbol (if (eq (car placeholder) 'inlambda)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2424 'inline-close
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2425 'block-close))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2426 (goto-char containing-sexp)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2427 (back-to-indentation)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2428 (if (= containing-sexp (point))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2429 (c-add-syntax tmpsymbol (point))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2430 (goto-char (cdr placeholder))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2431 (back-to-indentation)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2432 (c-add-syntax tmpsymbol (point))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2433 (if (/= (point) (cdr placeholder))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2434 (c-add-syntax (car placeholder)))))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2435 ;; CASE 16B: does this close an inline or a function in
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
2436 ;; an extern block or namespace?
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
2437 ((progn
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
2438 (goto-char containing-sexp)
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
2439 (setq placeholder (c-search-uplist-for-classkey state)))
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
2440 (goto-char (aref placeholder 0))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2441 (if (looking-at (concat c-extra-toplevel-key "[^_]"))
21106
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
2442 (c-add-syntax 'defun-close relpos)
5e5fa0a34cb0 (c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents: 20914
diff changeset
2443 (c-add-syntax 'inline-close relpos)))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2444 ;; CASE 16C: if there an enclosing brace that hasn't
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2445 ;; been narrowed out by a class, then this is a
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2446 ;; block-close
20914
8f189ffad604 (c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents: 20142
diff changeset
2447 ((and (not inenclosing-p)
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2448 (c-most-enclosing-brace state)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2449 (or (not (c-major-mode-is 'pike-mode))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2450 ;; In Pike it can be a defun-close of a
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2451 ;; function declared in a statement block. Let
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2452 ;; it through to be handled below.
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2453 (or (c-looking-at-bos)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2454 (progn
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2455 (c-beginning-of-statement-1)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2456 (looking-at c-conditional-key)))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2457 (c-add-syntax 'block-close relpos))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2458 ;; CASE 16D: find out whether we're closing a top-level
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2459 ;; class or a defun
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2460 (t
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2461 (save-restriction
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2462 (narrow-to-region (point-min) indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2463 (let ((decl (c-search-uplist-for-classkey (c-parse-state))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2464 (if decl
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2465 (c-add-class-syntax 'class-close decl)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2466 (c-add-syntax 'defun-close relpos)))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2467 )))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2468 ;; CASE 17: statement catchall
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2469 (t
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2470 ;; we know its a statement, but we need to find out if it is
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2471 ;; the first statement in a block
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2472 (goto-char containing-sexp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2473 (forward-char 1)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2474 (c-forward-syntactic-ws indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2475 ;; now skip forward past any case/default clauses we might find.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2476 (while (or (c-skip-case-statement-forward fullstate indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2477 (and (looking-at c-switch-label-key)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2478 (not inswitch-p)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2479 (setq inswitch-p t))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2480 ;; we want to ignore non-case labels when skipping forward
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2481 (while (and (looking-at c-label-key)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2482 (goto-char (match-end 0)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2483 (c-forward-syntactic-ws indent-point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2484 (cond
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2485 ;; CASE 17A: we are inside a case/default clause inside a
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2486 ;; switch statement. find out if we are at the statement
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2487 ;; just after the case/default label.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2488 ((and inswitch-p
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2489 (progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2490 (goto-char indent-point)
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2491 (c-beginning-of-statement-1 containing-sexp)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2492 (setq placeholder (point))
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2493 (beginning-of-line)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2494 (when (re-search-forward c-switch-label-key
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2495 (max placeholder (c-point 'eol)) t)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2496 (setq placeholder (match-beginning 0)))))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2497 (goto-char indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2498 (skip-chars-forward " \t")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2499 (if (eq (char-after) ?{)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2500 (c-add-syntax 'statement-case-open placeholder)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2501 (c-add-syntax 'statement-case-intro placeholder)))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2502 ;; CASE 17B: continued statement
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2503 ((eq char-before-ip ?,)
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2504 (goto-char indent-point)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2505 (c-beginning-of-closest-statement)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2506 (c-add-syntax 'statement-cont (c-point 'boi)))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2507 ;; CASE 17C: a question/colon construct? But make sure
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2508 ;; what came before was not a label, and what comes after
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2509 ;; is not a globally scoped function call!
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2510 ((or (and (memq char-before-ip '(?: ??))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2511 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2512 (goto-char indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2513 (c-backward-syntactic-ws lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2514 (back-to-indentation)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2515 (not (looking-at c-label-key))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2516 (and (memq char-after-ip '(?: ??))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2517 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2518 (goto-char indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2519 (skip-chars-forward " \t")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2520 ;; watch out for scope operator
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2521 (not (looking-at "::")))))
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2522 (goto-char indent-point)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2523 (c-beginning-of-closest-statement)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2524 (c-add-syntax 'statement-cont (c-point 'boi)))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2525 ;; CASE 17D: any old statement
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2526 ((< (point) indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2527 (let ((safepos (c-most-enclosing-brace fullstate))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2528 relpos done)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2529 (goto-char indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2530 (c-beginning-of-statement-1 safepos)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2531 ;; It is possible we're on the brace that opens a nested
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2532 ;; function.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2533 (if (and (eq (char-after) ?{)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2534 (save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2535 (c-backward-syntactic-ws safepos)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2536 (not (eq (char-before) ?\;))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2537 (c-beginning-of-statement-1 safepos))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2538 (if (and inswitch-p
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2539 (looking-at c-switch-label-key))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2540 (progn
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2541 (goto-char (match-end 0))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2542 (c-forward-syntactic-ws)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2543 (setq relpos (c-point 'boi))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2544 (while (and (not done)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2545 (<= safepos (point))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2546 (/= relpos (point)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2547 (c-beginning-of-statement-1 safepos)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2548 (if (= relpos (c-point 'boi))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2549 (setq done t))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2550 (setq relpos (c-point 'boi)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2551 (c-add-syntax 'statement relpos)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2552 (if (eq char-after-ip ?{)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2553 (c-add-syntax 'block-open))))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2554 ;; CASE 17E: first statement in an in-expression block
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2555 ((setq placeholder
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2556 (save-excursion
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2557 (goto-char containing-sexp)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2558 (c-looking-at-inexpr-block)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2559 (goto-char containing-sexp)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2560 (back-to-indentation)
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2561 (let ((block-intro (if (eq (car placeholder) 'inlambda)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2562 'defun-block-intro
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2563 'statement-block-intro)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2564 (if (= containing-sexp (point))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2565 (c-add-syntax block-intro (point))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2566 (goto-char (cdr placeholder))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2567 (back-to-indentation)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2568 (c-add-syntax block-intro (point))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2569 (if (/= (point) (cdr placeholder))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2570 (c-add-syntax (car placeholder)))))
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2571 (if (eq char-after-ip ?{)
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2572 (c-add-syntax 'block-open)))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2573 ;; CASE 17F: first statement in an inline, or first
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2574 ;; statement in a top-level defun. we can tell this is it
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2575 ;; if there are no enclosing braces that haven't been
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2576 ;; narrowed out by a class (i.e. don't use bod here!)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2577 ((save-excursion
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2578 (save-restriction
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2579 (widen)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2580 (goto-char containing-sexp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2581 (c-narrow-out-enclosing-class state containing-sexp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2582 (not (c-most-enclosing-brace state))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2583 (goto-char containing-sexp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2584 ;; if not at boi, then defun-opening braces are hung on
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2585 ;; right side, so we need a different relpos
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2586 (if (/= (point) (c-point 'boi))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2587 (progn
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2588 (c-backward-syntactic-ws)
24282
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2589 (c-safe (c-forward-sexp (if (eq (char-before) ?\))
5b0864259a4b Installed CC Mode 5.25.
Barry A. Warsaw <barry@zope.org>
parents: 21106
diff changeset
2590 -1 -2)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2591 ;; looking at a Java throws clause following a
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2592 ;; method's parameter list
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2593 (c-beginning-of-statement-1)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2594 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2595 (c-add-syntax 'defun-block-intro (c-point 'boi)))
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2596 ;; CASE 17G: First statement in a function declared inside
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2597 ;; a normal block. This can only occur in Pike.
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2598 ((and (c-major-mode-is 'pike-mode)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2599 (progn
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2600 (goto-char containing-sexp)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2601 (and (not (c-looking-at-bos))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2602 (progn
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2603 (c-beginning-of-statement-1)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2604 (not (looking-at c-conditional-key))))))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2605 (c-add-syntax 'defun-block-intro (c-point 'boi)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2606 ;; CASE 17H: first statement in a block
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2607 (t (goto-char containing-sexp)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2608 (if (/= (point) (c-point 'boi))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2609 (c-beginning-of-statement-1
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2610 (if (= (point) lim)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2611 (c-safe-position (point) state) lim)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2612 (c-add-syntax 'statement-block-intro (c-point 'boi))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2613 (if (eq char-after-ip ?{)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2614 (c-add-syntax 'block-open)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2615 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2616 )
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2617 ;; now we need to look at any modifiers
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2618 (goto-char indent-point)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2619 (skip-chars-forward " \t")
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2620 (cond
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2621 ;; are we looking at a comment only line?
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2622 ((and (looking-at c-comment-start-regexp)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2623 (/= (c-forward-token-1 0 nil (c-point 'eol)) 0))
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2624 (c-add-syntax 'comment-intro))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2625 ;; we might want to give additional offset to friends (in C++).
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2626 ((and (c-major-mode-is 'c++-mode)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2627 (looking-at c-C++-friend-key))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2628 (c-add-syntax 'friend))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2629 ;; Start of a preprocessor directive?
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2630 ((and (eq literal 'pound)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2631 (= (save-excursion
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2632 (c-beginning-of-macro lim)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2633 (setq placeholder (point)))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2634 (c-point 'boi))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2635 (not (and (c-major-mode-is 'pike-mode)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2636 (eq (char-after (1+ placeholder)) ?\"))))
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2637 (c-add-syntax 'cpp-macro)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2638 ;; return the syntax
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2639 syntax))))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2640
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2641
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2642 (defun c-echo-parsing-error (&optional quiet)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2643 (when (and c-parsing-error (not quiet))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2644 (message "%s" c-parsing-error)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2645 (ding))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2646 c-parsing-error)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2647
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2648 (defun c-shift-line-indentation (shift-amt)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2649 (let ((pos (- (point-max) (point)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2650 (col (current-indentation)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2651 (if (zerop shift-amt)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2652 nil
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2653 (delete-region (c-point 'bol) (c-point 'boi))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2654 (beginning-of-line)
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2655 (indent-to (+ col shift-amt)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2656 (if (< (point) (c-point 'boi))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2657 (back-to-indentation)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2658 ;; If initial point was within line's indentation, position after
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2659 ;; the indentation. Else stay at same point in text.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2660 (if (> (- (point-max) pos) (point))
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2661 (goto-char (- (point-max) pos))))))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2662
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2663 (defun c-evaluate-offset (offset langelem symbol)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2664 ;; 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
2665 ;; the symbols + or -
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2666 (cond
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2667 ((eq offset '+) c-basic-offset)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2668 ((eq offset '-) (- c-basic-offset))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2669 ((eq offset '++) (* 2 c-basic-offset))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2670 ((eq offset '--) (* 2 (- c-basic-offset)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2671 ((eq offset '*) (/ c-basic-offset 2))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2672 ((eq offset '/) (/ (- c-basic-offset) 2))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2673 ((numberp offset) offset)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2674 ((functionp offset) (c-evaluate-offset
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2675 (funcall offset langelem) langelem symbol))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2676 ((vectorp offset) offset)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2677 ((null offset) nil)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2678 ((listp offset)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2679 (let (done)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2680 (while (and (not done) offset)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2681 (setq done (c-evaluate-offset (car offset) langelem symbol)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2682 offset (cdr offset)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2683 (if (not done)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2684 (if c-strict-syntax-p
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2685 (error "No offset found for syntactic symbol %s" symbol))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2686 done)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2687 (t (symbol-value offset))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2688 ))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2689
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2690 (defun c-get-offset (langelem)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2691 ;; Get offset from LANGELEM which is a cons cell of the form:
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2692 ;; (SYMBOL . RELPOS). The symbol is matched against
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2693 ;; c-offsets-alist and the offset found there is either returned,
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2694 ;; or added to the indentation at RELPOS. If RELPOS is nil, then
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2695 ;; the offset is simply returned.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2696 (let* ((symbol (car langelem))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2697 (relpos (cdr langelem))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2698 (match (assq symbol c-offsets-alist))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2699 (offset (cdr-safe match)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2700 (if (not match)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2701 (if c-strict-syntax-p
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2702 (error "No offset found for syntactic symbol %s" symbol)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2703 (setq offset 0
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2704 relpos 0))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2705 (setq offset (c-evaluate-offset offset langelem symbol)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2706 (if (vectorp offset)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2707 offset
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2708 (+ (if (and relpos
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2709 (< relpos (c-point 'bol)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2710 (save-excursion
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2711 (goto-char relpos)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2712 (current-column))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2713 0)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2714 (or (and (numberp offset) offset)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2715 (and (symbolp offset) (symbol-value offset))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2716 0)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2717 ))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2718
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2719 (defun c-get-syntactic-indentation (langelems)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2720 ;; Apply c-get-offset to a list of langelem cells to get the total
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2721 ;; syntactic indentation. Special treatment is needed for vectors
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2722 ;; containing absolute columns.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2723 (let ((indent 0))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2724 (catch 'done
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2725 (while langelems
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2726 (let ((res (c-get-offset (car langelems))))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2727 (if (vectorp res)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2728 (throw 'done (elt res 0))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2729 (setq indent (+ indent res)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2730 langelems (cdr langelems)))))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2731 indent)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2732
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2733 (defun c-indent-line (&optional syntax quiet)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2734 ;; Indent the current line according to the syntactic context, if
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2735 ;; c-syntactic-indentation is non-nil. Optional SYNTAX is the
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2736 ;; syntactic information for the current line. Be silent about
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2737 ;; syntactic errors if the optional argument QUIET is non-nil.
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2738 ;; Returns the amount of indentation change (in columns).
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2739 (let (shift-amt)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2740 (if c-syntactic-indentation
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2741 (setq c-parsing-error
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2742 (or (let* ((c-parsing-error nil)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2743 (c-syntactic-context (or syntax
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2744 c-syntactic-context
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2745 (c-guess-basic-syntax)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2746 (indent (c-get-syntactic-indentation c-syntactic-context)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2747 (and (not (c-echo-parsing-error quiet))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2748 c-echo-syntactic-information-p
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2749 (message "syntax: %s, indent: %d"
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2750 c-syntactic-context indent))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2751 (setq shift-amt (- indent (current-indentation)))
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2752 (c-shift-line-indentation shift-amt)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2753 (run-hooks 'c-special-indent-hook)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2754 c-parsing-error)
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2755 c-parsing-error))
30403
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2756 (let ((indent 0))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2757 (save-excursion
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2758 (while (and (= (forward-line -1) 0)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2759 (if (looking-at "\\s-*$")
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2760 t
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2761 (back-to-indentation)
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2762 (setq indent (current-indentation))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2763 nil))))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2764 (setq shift-amt (- indent (current-indentation)))
68e734ab7d5d (c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents: 26817
diff changeset
2765 (c-shift-line-indentation shift-amt)))
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2766 shift-amt))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2767
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2768 (defun c-show-syntactic-information (arg)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2769 "Show syntactic information for current line.
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2770 With universal argument, inserts the analysis as a comment on that line."
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2771 (interactive "P")
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2772 (let ((syntax (c-guess-basic-syntax)))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2773 (if (not (consp arg))
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2774 (message "syntactic analysis: %s" syntax)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2775 (indent-for-comment)
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2776 (insert (format "%s" syntax))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2777 ))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2778 (c-keep-region-active))
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2779
26817
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2780 (defun c-syntactic-information-on-region (from to)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2781 "Inserts a comment with the syntactic analysis on every line in the region."
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2782 (interactive "*r")
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2783 (save-excursion
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2784 (save-restriction
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2785 (narrow-to-region from to)
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2786 (goto-char (point-min))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2787 (while (not (eobp))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2788 (c-show-syntactic-information '(0))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2789 (forward-line)))))
03befb219d03 Installed version 5.26
Gerd Moellmann <gerd@gnu.org>
parents: 25178
diff changeset
2790
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2791
36920
32a4317c6aa5 Update to version 5.28.
Gerd Moellmann <gerd@gnu.org>
parents: 34304
diff changeset
2792 (cc-provide 'cc-engine)
18720
fc6d08b9bbe2 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
2793 ;;; cc-engine.el ends here