Mercurial > emacs
annotate lisp/progmodes/cc-engine.el @ 46937:e406ed027b71
Escape an `@'.
author | Miles Bader <miles@gnu.org> |
---|---|
date | Mon, 19 Aug 2002 01:05:17 +0000 |
parents | 07e19a2737a1 |
children | 35f3b5d4f918 |
rev | line source |
---|---|
18720 | 1 ;;; cc-engine.el --- core syntax guessing engine for CC mode |
2 | |
36920 | 3 ;; Copyright (C) 1985,1987,1992-2001 Free Software Foundation, Inc. |
18720 | 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 | 7 ;; 1992-1997 Barry A. Warsaw |
18720 | 8 ;; 1987 Dave Detlefs and Stewart Clamen |
9 ;; 1985 Richard M. Stallman | |
24282 | 10 ;; Maintainer: bug-cc-mode@gnu.org |
18720 | 11 ;; Created: 22-Apr-1997 (split from cc-mode.el) |
20142 | 12 ;; Version: See cc-mode.el |
18720 | 13 ;; Keywords: c languages oop |
14 | |
15 ;; This file is part of GNU Emacs. | |
16 | |
17 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
18 ;; it under the terms of the GNU General Public License as published by | |
19 ;; the Free Software Foundation; either version 2, or (at your option) | |
20 ;; any later version. | |
21 | |
22 ;; GNU Emacs is distributed in the hope that it will be useful, | |
23 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
24 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
25 ;; GNU General Public License for more details. | |
26 | |
27 ;; You should have received a copy of the GNU General Public License | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
28 ;; along with GNU Emacs; see the file COPYING. If not, write to |
36920 | 29 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18720 | 30 ;; Boston, MA 02111-1307, USA. |
31 | |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
32 ;;; Commentary: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
33 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
34 ;; The functions which have docstring documentation can be considered |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
35 ;; part of an API which other packages can use in CC Mode buffers. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
36 ;; Otoh, undocumented functions and functions with the documentation |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
37 ;; in comments are considered purely internal and can change semantics |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
38 ;; or even disappear in the future. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
39 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
40 ;; (This policy applies to CC Mode as a whole, not just this file. It |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
41 ;; probably also applies to many other Emacs packages, but here it's |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
42 ;; clearly spelled out.) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
43 |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
44 ;;; Code: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
45 |
26817 | 46 (eval-when-compile |
47 (let ((load-path | |
36920 | 48 (if (and (boundp 'byte-compile-dest-file) |
49 (stringp byte-compile-dest-file)) | |
50 (cons (file-name-directory byte-compile-dest-file) load-path) | |
26817 | 51 load-path))) |
36920 | 52 (require 'cc-bytecomp))) |
53 | |
54 (cc-require 'cc-defs) | |
55 (cc-require 'cc-vars) | |
56 (cc-require 'cc-langs) | |
57 | |
58 ;; Silence the compiler. | |
59 (cc-bytecomp-defun buffer-syntactic-context) ; XEmacs | |
26817 | 60 |
18720 | 61 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
62 (defun c-calculate-state (arg prevstate) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
63 ;; Calculate the new state of PREVSTATE, t or nil, based on arg. If |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
64 ;; arg is nil or zero, toggle the state. If arg is negative, turn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
65 ;; the state off, and if arg is positive, turn the state on |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
66 (if (or (not arg) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
67 (zerop (setq arg (prefix-numeric-value arg)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
68 (not prevstate) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
69 (> arg 0))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
70 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
71 |
36920 | 72 (defvar c-in-literal-cache t) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
73 (defvar c-parsing-error nil) |
36920 | 74 |
18844
6b269c4ad2eb
(c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
75 ;; 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
|
76 ;; 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
|
77 ;; 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
|
78 ;; the byte compiler. |
6b269c4ad2eb
(c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
79 (defvar c-maybe-labelp nil) |
6b269c4ad2eb
(c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
80 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
81 ;; Macros used internally in c-beginning-of-statement-1 for the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
82 ;; automaton actions. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
83 (defmacro c-bos-push-state () |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
84 '(setq stack (cons (cons state saved-pos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
85 stack))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
86 (defmacro c-bos-pop-state (&optional do-if-done) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
87 `(if (setq state (car (car stack)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
88 saved-pos (cdr (car stack)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
89 stack (cdr stack)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
90 t |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
91 ,do-if-done |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
92 (throw 'loop nil))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
93 (defmacro c-bos-pop-state-and-retry () |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
94 '(throw 'loop (setq state (car (car stack)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
95 saved-pos (cdr (car stack)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
96 ;; Throw nil if stack is empty, else throw non-nil. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
97 stack (cdr stack)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
98 (defmacro c-bos-save-pos () |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
99 '(setq saved-pos (vector pos tok ptok pptok))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
100 (defmacro c-bos-restore-pos () |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
101 '(unless (eq (elt saved-pos 0) start) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
102 (setq pos (elt saved-pos 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
103 tok (elt saved-pos 1) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
104 ptok (elt saved-pos 2) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
105 pptok (elt saved-pos 3)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
106 (goto-char pos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
107 (setq sym nil))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
108 (defmacro c-bos-save-error-info (missing got) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
109 `(setq saved-pos (vector pos ,missing ,got))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
110 (defmacro c-bos-report-error () |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
111 '(unless noerror |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
112 (setq c-parsing-error |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
113 (format "No matching `%s' found for `%s' on line %d" |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
114 (elt saved-pos 1) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
115 (elt saved-pos 2) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
116 (1+ (count-lines (point-min) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
117 (c-point 'bol (elt saved-pos 0)))))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
118 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
119 (defun c-beginning-of-statement-1 (&optional lim ignore-labels |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
120 noerror comma-delim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
121 "Move to the start of the current statement or declaration, or to |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
122 the previous one if already at the beginning of one. Only |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
123 statements/declarations on the same level are considered, i.e. don't |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
124 move into or out of sexps (not even normal expression parentheses). |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
125 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
126 Stop at statement continuations like \"else\", \"catch\", \"finally\" |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
127 and the \"while\" in \"do ... while\" if the start point is within |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
128 them. If starting at such a continuation, move to the corresponding |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
129 statement start. If at the beginning of a statement, move to the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
130 closest containing statement if there is any. This might also stop at |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
131 a continuation clause. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
132 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
133 Labels are treated as separate statements if IGNORE-LABELS is non-nil. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
134 The function is not overly intelligent in telling labels from other |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
135 uses of colons; if used outside a statement context it might trip up |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
136 on e.g. inherit colons, so IGNORE-LABELS should be used then. There |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
137 should be no such mistakes in a statement context, however. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
138 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
139 Macros are ignored unless point is within one, in which case the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
140 content of the macro is treated as normal code. Aside from any normal |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
141 statement starts found in it, stop at the first token of the content |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
142 in the macro, i.e. the expression of an \"#if\" or the start of the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
143 definition in a \"#define\". Also stop at start of macros before |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
144 leaving them. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
145 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
146 Return 'label if stopped at a label, 'same if stopped at the beginning |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
147 of the current statement, 'up if stepped to a containing statement, |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
148 'previous if stepped to a preceding statement, 'beginning if stepped |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
149 from a statement continuation clause to its start clause, or 'macro if |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
150 stepped to a macro start. Note that 'same and not 'label is returned |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
151 if stopped at the same label without crossing the colon character. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
152 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
153 LIM may be given to limit the search. If the search hits the limit, |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
154 point will be left at the closest following token, or at the start |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
155 position if that is less ('same is returned in this case). |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
156 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
157 NOERROR turns off error logging to `c-parsing-error'. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
158 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
159 Normally only ';' is considered to delimit statements, but if |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
160 COMMA-DELIM is non-nil then ',' is treated likewise." |
18720 | 161 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
162 ;; The bulk of this function is a pushdown automaton that looks at |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
163 ;; statement boundaries and the tokens in c-opt-block-stmt-key. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
164 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
165 ;; Note: The position of a boundary is the following token. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
166 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
167 ;; Begin with current token, stop when stack is empty and the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
168 ;; position has been moved. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
169 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
170 ;; Common state: |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
171 ;; "else": Push state, goto state `else': |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
172 ;; boundary: Goto state `else-boundary': |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
173 ;; "if": Pop state. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
174 ;; boundary: Error, pop state. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
175 ;; other: See common state. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
176 ;; other: Error, pop state, retry token. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
177 ;; "while": Push state, goto state `while': |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
178 ;; boundary: Save position, goto state `while-boundary': |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
179 ;; "do": Pop state. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
180 ;; boundary: Restore position if it's not at start, pop state. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
181 ;; other: See common state. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
182 ;; other: Pop state, retry token. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
183 ;; "catch" or "finally": Push state, goto state `catch': |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
184 ;; boundary: Goto state `catch-boundary': |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
185 ;; "try": Pop state. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
186 ;; "catch": Goto state `catch'. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
187 ;; boundary: Error, pop state. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
188 ;; other: See common state. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
189 ;; other: Error, pop state, retry token. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
190 ;; other: Do nothing special. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
191 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
192 ;; In addition to the above there is some special handling of labels |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
193 ;; and macros. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
194 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
195 (let ((case-fold-search nil) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
196 (start (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
197 macro-start |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
198 (delims (if comma-delim '(?\; ?,) '(?\;))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
199 (c-stmt-delim-chars (if comma-delim |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
200 c-stmt-delim-chars-with-comma |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
201 c-stmt-delim-chars)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
202 pos ; Current position. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
203 boundary-pos ; Position of last boundary. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
204 after-labels-pos ; Value of tok after first found colon. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
205 last-label-pos ; Value of tok after last found colon. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
206 sym ; Current symbol in the alphabet. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
207 state ; Current state in the automaton. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
208 saved-pos ; Current saved positions. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
209 stack ; Stack of conses (state . saved-pos). |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
210 (cond-key (or c-opt-block-stmt-key |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
211 "\\<\\>")) ; Matches nothing. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
212 (ret 'same) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
213 tok ptok pptok ; Pos of last three sexps or bounds. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
214 c-in-literal-cache c-maybe-labelp saved) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
215 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
216 (save-restriction |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
217 (if lim (narrow-to-region lim (point-max))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
218 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
219 (if (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
220 (and (c-beginning-of-macro) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
221 (/= (point) start))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
222 (setq macro-start (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
223 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
224 ;; Try to skip over unary operator characters, to register |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
225 ;; that we've moved. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
226 (while (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
227 (setq pos (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
228 (c-backward-syntactic-ws) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
229 (/= (skip-chars-backward "-+!*&~@`#") 0))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
230 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
231 ;; First check for bare semicolon. Later on we ignore the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
232 ;; boundaries for statements that doesn't contain any sexp. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
233 ;; The only thing that is affected is that the error checking |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
234 ;; is a little less strict, and we really don't bother. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
235 (if (and (memq (char-before) delims) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
236 (progn (forward-char -1) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
237 (setq saved (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
238 (c-backward-syntactic-ws) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
239 (or (memq (char-before) delims) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
240 (memq (char-before) '(?: nil)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
241 (eq (char-syntax (char-before)) ?\()))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
242 (setq ret 'previous |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
243 pos saved) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
244 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
245 ;; Begin at start and not pos to detect macros if we stand |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
246 ;; directly after the #. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
247 (goto-char start) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
248 (if (looking-at "\\<\\|\\W") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
249 ;; Record this as the first token if not starting inside it. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
250 (setq tok start)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
251 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
252 (while |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
253 (catch 'loop ;; Throw nil to break, non-nil to continue. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
254 (cond |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
255 ;; Check for macro start. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
256 ((save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
257 (and macro-start |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
258 (looking-at "[ \t]*[a-zA-Z0-9!]") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
259 (progn (skip-chars-backward " \t") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
260 (eq (char-before) ?#)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
261 (progn (setq saved (1- (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
262 (beginning-of-line) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
263 (not (eq (char-before (1- (point))) ?\\))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
264 (progn (skip-chars-forward " \t") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
265 (eq (point) saved)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
266 (goto-char saved) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
267 (if (and (c-forward-to-cpp-define-body) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
268 (progn (c-forward-syntactic-ws start) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
269 (< (point) start))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
270 ;; Stop at the first token in the content of the macro. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
271 (setq pos (point) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
272 ignore-labels t) ; Avoid the label check on exit. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
273 (setq pos saved |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
274 ret 'macro |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
275 ignore-labels t)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
276 (throw 'loop nil)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
277 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
278 ;; Do a round through the automaton if we found a |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
279 ;; boundary or if looking at a statement keyword. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
280 ((or sym |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
281 (and (looking-at cond-key) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
282 (setq sym (intern (match-string 1))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
283 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
284 (when (and (< pos start) (null stack)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
285 (throw 'loop nil)) |
18720 | 286 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
287 ;; The state handling. Continue in the common state for |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
288 ;; unhandled cases. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
289 (or (cond |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
290 ((eq state 'else) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
291 (if (eq sym 'boundary) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
292 (setq state 'else-boundary) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
293 (c-bos-report-error) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
294 (c-bos-pop-state-and-retry))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
295 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
296 ((eq state 'else-boundary) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
297 (cond ((eq sym 'if) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
298 (c-bos-pop-state (setq ret 'beginning))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
299 ((eq sym 'boundary) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
300 (c-bos-report-error) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
301 (c-bos-pop-state)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
302 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
303 ((eq state 'while) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
304 (if (and (eq sym 'boundary) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
305 ;; Since this can cause backtracking we do a |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
306 ;; little more careful analysis to avoid it: |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
307 ;; If there's a label in front of the while |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
308 ;; it can't be part of a do-while. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
309 (not after-labels-pos)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
310 (progn (c-bos-save-pos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
311 (setq state 'while-boundary)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
312 (c-bos-pop-state-and-retry))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
313 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
314 ((eq state 'while-boundary) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
315 (cond ((eq sym 'do) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
316 (c-bos-pop-state (setq ret 'beginning))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
317 ((eq sym 'boundary) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
318 (c-bos-restore-pos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
319 (c-bos-pop-state)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
320 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
321 ((eq state 'catch) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
322 (if (eq sym 'boundary) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
323 (setq state 'catch-boundary) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
324 (c-bos-report-error) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
325 (c-bos-pop-state-and-retry))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
326 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
327 ((eq state 'catch-boundary) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
328 (cond |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
329 ((eq sym 'try) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
330 (c-bos-pop-state (setq ret 'beginning))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
331 ((eq sym 'catch) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
332 (setq state 'catch)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
333 ((eq sym 'boundary) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
334 (c-bos-report-error) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
335 (c-bos-pop-state))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
336 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
337 ;; This is state common. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
338 (cond ((eq sym 'boundary) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
339 (if (< pos start) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
340 (c-bos-pop-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
341 (c-bos-push-state))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
342 ((eq sym 'else) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
343 (c-bos-push-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
344 (c-bos-save-error-info 'if 'else) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
345 (setq state 'else)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
346 ((eq sym 'while) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
347 (when (or (not pptok) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
348 (memq (char-after pptok) delims)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
349 ;; Since this can cause backtracking we do a |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
350 ;; little more careful analysis to avoid it: If |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
351 ;; the while isn't followed by a semicolon it |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
352 ;; can't be a do-while. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
353 (c-bos-push-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
354 (setq state 'while))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
355 ((memq sym '(catch finally)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
356 (c-bos-push-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
357 (c-bos-save-error-info 'try sym) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
358 (setq state 'catch)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
359 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
360 (when c-maybe-labelp |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
361 ;; We're either past a statement boundary or at the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
362 ;; start of a statement, so throw away any label data |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
363 ;; for the previous one. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
364 (setq after-labels-pos nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
365 last-label-pos nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
366 c-maybe-labelp nil)))) |
18720 | 367 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
368 ;; Step to next sexp, but not if we crossed a boundary, since |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
369 ;; that doesn't consume an sexp. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
370 (if (eq sym 'boundary) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
371 (setq ret 'previous) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
372 (while |
19377
989d0412ada3
(c-end-of-statement-1): Eliminate false hits on important characters
Richard M. Stallman <rms@gnu.org>
parents:
19301
diff
changeset
|
373 (progn |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
374 (or (c-safe (goto-char (scan-sexps (point) -1)) t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
375 (throw 'loop nil)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
376 (cond ((looking-at "\\\\$") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
377 ;; Step again if we hit a line continuation. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
378 t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
379 (macro-start |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
380 ;; If we started inside a macro then this |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
381 ;; sexp is always interesting. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
382 nil) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
383 (t |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
384 ;; Otherwise check that we didn't step |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
385 ;; into a macro from the end. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
386 (let ((macro-start |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
387 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
388 (and (c-beginning-of-macro) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
389 (point))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
390 (when macro-start |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
391 (goto-char macro-start) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
392 t)))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
393 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
394 ;; Check for statement boundary. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
395 (when (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
396 (if (if (eq (char-after) ?{) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
397 (c-looking-at-inexpr-block lim nil) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
398 (eq (char-syntax (char-after)) ?\()) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
399 ;; Need to move over parens and |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
400 ;; in-expression blocks to get a good start |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
401 ;; position for the boundary check. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
402 (c-forward-sexp 1)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
403 (setq boundary-pos (c-crosses-statement-barrier-p |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
404 (point) pos))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
405 (setq pptok ptok |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
406 ptok tok |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
407 tok boundary-pos |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
408 sym 'boundary) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
409 (throw 'loop t))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
410 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
411 (when (and (numberp c-maybe-labelp) (not ignore-labels)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
412 ;; c-crosses-statement-barrier-p has found a colon, so |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
413 ;; we might be in a label now. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
414 (if (not after-labels-pos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
415 (setq after-labels-pos tok)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
416 (setq last-label-pos tok |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
417 c-maybe-labelp t)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
418 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
419 ;; ObjC method def? |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
420 (when (and c-opt-method-key |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
421 (setq saved (c-in-method-def-p))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
422 (setq pos saved |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
423 ignore-labels t) ; Avoid the label check on exit. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
424 (throw 'loop nil)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
425 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
426 (setq sym nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
427 pptok ptok |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
428 ptok tok |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
429 tok (point) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
430 pos tok))) ; Not nil. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
431 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
432 ;; If the stack isn't empty there might be errors to report. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
433 (while stack |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
434 (if (and (vectorp saved-pos) (eq (length saved-pos) 3)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
435 (c-bos-report-error)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
436 (setq saved-pos (cdr (car stack)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
437 stack (cdr stack))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
438 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
439 (when (and (eq ret 'same) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
440 (not (memq sym '(boundary ignore nil)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
441 ;; Need to investigate closer whether we've crossed |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
442 ;; between a substatement and its containing statement. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
443 (if (setq saved (if (looking-at c-block-stmt-1-key) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
444 ptok |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
445 pptok)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
446 (cond ((> start saved) (setq pos saved)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
447 ((= start saved) (setq ret 'up))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
448 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
449 (when (and c-maybe-labelp (not ignore-labels) after-labels-pos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
450 ;; We're in a label. Maybe we should step to the statement |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
451 ;; after it. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
452 (if (< after-labels-pos start) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
453 (setq pos after-labels-pos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
454 (setq ret 'label) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
455 (if (< last-label-pos start) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
456 (setq pos last-label-pos))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
457 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
458 ;; Skip over the unary operators that can start the statement. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
459 (goto-char pos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
460 (while (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
461 (c-backward-syntactic-ws) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
462 (/= (skip-chars-backward "-+!*&~@`#") 0)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
463 (setq pos (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
464 (goto-char pos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
465 ret))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
466 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
467 (defun c-crosses-statement-barrier-p (from to) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
468 "Return non-nil if buffer positions FROM to TO cross one or more |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
469 statement or declaration boundaries. The returned value is actually |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
470 the position of the earliest boundary char. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
471 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
472 The variable `c-maybe-labelp' is set to the position of the first `:' that |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
473 might start a label (i.e. not part of `::' and not preceded by `?'). If a |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
474 single `?' is found, then `c-maybe-labelp' is cleared." |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
475 (let ((skip-chars c-stmt-delim-chars) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
476 lit-range) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
477 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
478 (catch 'done |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
479 (goto-char from) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
480 (while (progn (skip-chars-forward skip-chars to) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
481 (< (point) to)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
482 (if (setq lit-range (c-literal-limits from)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
483 (goto-char (setq from (cdr lit-range))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
484 (cond ((eq (char-after) ?:) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
485 (forward-char) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
486 (if (and (eq (char-after) ?:) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
487 (< (point) to)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
488 ;; Ignore scope operators. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
489 (forward-char) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
490 (setq c-maybe-labelp (1- (point))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
491 ((eq (char-after) ??) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
492 ;; A question mark. Can't be a label, so stop |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
493 ;; looking for more : and ?. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
494 (setq c-maybe-labelp nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
495 skip-chars (substring c-stmt-delim-chars 0 -2))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
496 (t (throw 'done (point)))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
497 nil)))) |
18720 | 498 |
499 | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
500 ;; This is a dynamically bound cache used together with |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
501 ;; c-query-macro-start and c-query-and-set-macro-start. It only works |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
502 ;; as long as point doesn't cross a macro boundary. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
503 (defvar c-macro-start 'unknown) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
504 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
505 (defsubst c-query-and-set-macro-start () |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
506 (if (symbolp c-macro-start) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
507 (setq c-macro-start (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
508 (and (c-beginning-of-macro) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
509 (point)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
510 c-macro-start)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
511 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
512 (defsubst c-query-macro-start () |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
513 (if (symbolp c-macro-start) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
514 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
515 (and (c-beginning-of-macro) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
516 (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
517 c-macro-start)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
518 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
519 (defun c-beginning-of-macro (&optional lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
520 "Go to the beginning of a cpp macro definition. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
521 Leave point at the beginning of the macro and return t if in a cpp |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
522 macro definition, otherwise return nil and leave point unchanged." |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
523 (let ((here (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
524 (save-restriction |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
525 (if lim (narrow-to-region lim (point-max))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
526 (beginning-of-line) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
527 (while (eq (char-before (1- (point))) ?\\) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
528 (forward-line -1)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
529 (back-to-indentation) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
530 (if (and (<= (point) here) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
531 (looking-at "#[ \t]*[a-zA-Z0-9!]")) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
532 t |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
533 (goto-char here) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
534 nil)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
535 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
536 (defun c-end-of-macro () |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
537 "Go to the end of a cpp macro definition. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
538 More accurately, move point to the end of the closest following line |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
539 that doesn't end with a line continuation backslash." |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
540 (while (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
541 (end-of-line) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
542 (when (and (eq (char-before) ?\\) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
543 (not (eobp))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
544 (forward-char) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
545 t)))) |
18720 | 546 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
547 (defun c-forward-comment (count) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
548 ;; Insulation from various idiosyncrasies in implementations of |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
549 ;; `forward-comment'. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
550 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
551 ;; Note: Some emacsen considers incorrectly that any line comment |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
552 ;; ending with a backslash continues to the next line. I can't |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
553 ;; think of any way to work around that in a reliable way without |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
554 ;; changing the buffer, though. Suggestions welcome. ;) (No, |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
555 ;; temporarily changing the syntax for backslash doesn't work since |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
556 ;; we must treat escapes in string literals correctly.) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
557 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
558 ;; Another note: When moving backwards over a block comment, there's |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
559 ;; a bug in forward-comment that can make it stop at "/*" inside a |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
560 ;; line comment. Haven't yet found a reasonably cheap way to kludge |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
561 ;; around that one either. :\ |
36920 | 562 (let ((here (point))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
563 (if (>= count 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
564 (when (forward-comment count) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
565 (if (eobp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
566 ;; Some emacsen (e.g. XEmacs 21) return t when moving |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
567 ;; forwards at eob. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
568 nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
569 ;; Emacs includes the ending newline in a b-style (c++) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
570 ;; comment, but XEmacs doesn't. We depend on the Emacs |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
571 ;; behavior (which also is symmetric). |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
572 (if (and (eolp) (nth 7 (parse-partial-sexp here (point)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
573 (condition-case nil (forward-char 1))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
574 t)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
575 ;; When we got newline terminated comments, |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
576 ;; forward-comment in all supported emacsen so far will |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
577 ;; stop at eol of each line not ending with a comment when |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
578 ;; moving backwards. The following corrects for it when |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
579 ;; count is -1. The other common case, when count is |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
580 ;; large and negative, works regardless. It's too much |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
581 ;; work to correct for the rest of the cases. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
582 (skip-chars-backward " \t\n\r\f") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
583 (if (bobp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
584 ;; Some emacsen return t when moving backwards at bob. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
585 nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
586 (re-search-forward "[\n\r]" here t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
587 (let* ((res (if (forward-comment count) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
588 (if (eolp) (forward-comment -1) t))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
589 (savepos (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
590 ;; XEmacs treats line continuations as whitespace (but only |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
591 ;; in the backward direction). |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
592 (while (and (progn (end-of-line) (< (point) here)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
593 (eq (char-before) ?\\)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
594 (setq res nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
595 savepos (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
596 (forward-line)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
597 (goto-char savepos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
598 res))))) |
36920 | 599 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
600 (defun c-forward-comment-lc (count) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
601 ;; Like `c-forward-comment', but treat line continuations as |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
602 ;; whitespace. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
603 (catch 'done |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
604 (if (> count 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
605 (while (if (c-forward-comment 1) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
606 (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
607 (setq count (1- count)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
608 (> count 0)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
609 (if (looking-at "\\\\$") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
610 (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
611 (forward-char) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
612 t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
613 (throw 'done nil)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
614 (while (if (c-forward-comment -1) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
615 (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
616 (setq count (1+ count)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
617 (< count 0)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
618 (if (and (eolp) (eq (char-before) ?\\)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
619 (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
620 (backward-char) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
621 t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
622 (throw 'done nil))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
623 t)) |
18720 | 624 |
625 (defun c-forward-syntactic-ws (&optional lim) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
626 "Forward skip of syntactic whitespace. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
627 Syntactic whitespace is defined as whitespace characters, comments, |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
628 and preprocessor directives. However if point starts inside a comment |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
629 or preprocessor directive, the content of it is not treated as |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
630 whitespace. LIM sets an upper limit of the forward movement, if |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
631 specified." |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
632 (let ((here (point-max))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
633 (or lim (setq lim here)) |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
634 (while (/= here (point)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
635 ;; If forward-comment in at least XEmacs 21 is given a large |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
636 ;; positive value, it'll loop all the way through if it hits eob. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
637 (while (c-forward-comment 5)) |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
638 (setq here (point)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
639 (cond |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
640 ;; Skip line continuations. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
641 ((looking-at "\\\\$") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
642 (forward-char)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
643 ;; Skip preprocessor directives. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
644 ((and (looking-at "#[ \t]*[a-zA-Z0-9!]") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
645 (progn (skip-chars-backward " \t") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
646 (bolp))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
647 (end-of-line) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
648 (while (and (<= (point) lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
649 (eq (char-before) ?\\) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
650 (= (forward-line 1) 0)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
651 (end-of-line)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
652 (when (> (point) lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
653 ;; Don't move past the macro if that'd take us past the limit. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
654 (goto-char here))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
655 ;; Skip in-comment line continuations (used for Pike refdoc). |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
656 ((and c-opt-in-comment-lc (looking-at c-opt-in-comment-lc)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
657 (goto-char (match-end 0))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
658 (goto-char (min (point) lim)))) |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
659 |
18720 | 660 (defun c-backward-syntactic-ws (&optional lim) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
661 "Backward skip of syntactic whitespace. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
662 Syntactic whitespace is defined as whitespace characters, comments, |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
663 and preprocessor directives. However if point starts inside a comment |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
664 or preprocessor directive, the content of it is not treated as |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
665 whitespace. LIM sets a lower limit of the backward movement, if |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
666 specified." |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
667 (let ((start-line (c-point 'bol)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
668 (here (point-min)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
669 (line-cont 'maybe) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
670 prev-pos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
671 (or lim (setq lim here)) |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
672 (while (/= here (point)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
673 (setq prev-pos (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
674 ;; If forward-comment in Emacs 19.34 is given a large negative |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
675 ;; value, it'll loop all the way through if it hits bob. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
676 (while (c-forward-comment -5)) |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
677 (setq here (point)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
678 (cond |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
679 ((and (eolp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
680 (eq (char-before) ?\\) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
681 (if (<= prev-pos (c-point 'eonl)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
682 t |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
683 ;; Passed a line continuation, but not from the line we |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
684 ;; started on. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
685 (forward-char) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
686 (setq line-cont nil))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
687 (backward-char) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
688 (setq line-cont t)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
689 ((progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
690 (when (eq line-cont 'maybe) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
691 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
692 (end-of-line) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
693 (setq line-cont (eq (char-before) ?\\)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
694 (or line-cont |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
695 (and (< (point) start-line) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
696 (c-beginning-of-macro)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
697 (if (< (point) lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
698 ;; Don't move past the macro if we began inside it or at |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
699 ;; the end of the same line, or if the move would take us |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
700 ;; past the limit. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
701 (goto-char here)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
702 (setq line-cont nil)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
703 ;; Skip in-comment line continuations (used for Pike refdoc). |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
704 ((and c-opt-in-comment-lc |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
705 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
706 (and (c-safe (beginning-of-line) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
707 (backward-char 2) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
708 t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
709 (looking-at c-opt-in-comment-lc) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
710 (eq (match-end 0) here)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
711 (goto-char (match-beginning 0))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
712 (goto-char (max (point) lim)))) |
21106
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
713 |
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
714 (defun c-forward-token-1 (&optional count balanced lim) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
715 "Move forward by tokens. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
716 A token is defined as all symbols and identifiers which aren't |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
717 syntactic whitespace \(note that e.g. \"->\" is considered to be two |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
718 tokens). Point is always either left at the beginning of a token or |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
719 not moved at all. COUNT specifies the number of tokens to move; a |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
720 negative COUNT moves in the opposite direction. A COUNT of 0 moves to |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
721 the next token beginning only if not already at one. If BALANCED is |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
722 true, move over balanced parens, otherwise move into them. Also, if |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
723 BALANCED is true, never move out of an enclosing paren. LIM sets the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
724 limit for the movement and defaults to the point limit. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
725 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
726 Return the number of tokens left to move \(positive or negative). If |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
727 BALANCED is true, a move over a balanced paren counts as one. Note |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
728 that if COUNT is 0 and no appropriate token beginning is found, 1 will |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
729 be returned. Thus, a return value of 0 guarantees that point is at |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
730 the requested position and a return value less \(without signs) than |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
731 COUNT guarantees that point is at the beginning of some token." |
24282 | 732 (or count (setq count 1)) |
733 (if (< count 0) | |
734 (- (c-backward-token-1 (- count) balanced lim)) | |
735 (let ((jump-syntax (if balanced | |
736 '(?w ?_ ?\( ?\) ?\" ?\\ ?/ ?$ ?') | |
737 '(?w ?_ ?\" ?\\ ?/ ?'))) | |
738 (last (point)) | |
739 (prev (point))) | |
740 (save-restriction | |
741 (if lim (narrow-to-region (point-min) lim)) | |
36920 | 742 (if (/= (point) |
743 (progn (c-forward-syntactic-ws) (point))) | |
744 ;; Skip whitespace. Count this as a move if we did in fact | |
745 ;; move and aren't out of bounds. | |
746 (or (eobp) | |
747 (setq count (max (1- count) 0)))) | |
748 (if (and (= count 0) | |
749 (or (and (memq (char-syntax (or (char-after) ? )) '(?w ?_)) | |
750 (memq (char-syntax (or (char-before) ? )) '(?w ?_))) | |
751 (eobp))) | |
752 ;; If count is zero we should jump if in the middle of a | |
753 ;; token or if there is whitespace between point and the | |
754 ;; following token beginning. | |
755 (setq count 1)) | |
24282 | 756 (if (eobp) |
757 (goto-char last) | |
36920 | 758 ;; Avoid having the limit tests inside the loop. |
24282 | 759 (condition-case nil |
760 (while (> count 0) | |
761 (setq prev last | |
762 last (point)) | |
763 (if (memq (char-syntax (char-after)) jump-syntax) | |
764 (goto-char (scan-sexps (point) 1)) | |
765 (forward-char)) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
766 (c-forward-syntactic-ws) |
24282 | 767 (setq count (1- count))) |
768 (error (goto-char last))) | |
769 (when (eobp) | |
770 (goto-char prev) | |
771 (setq count (1+ count))))) | |
772 count))) | |
21106
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
773 |
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
774 (defun c-backward-token-1 (&optional count balanced lim) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
775 "Move backward by tokens. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
776 See `c-forward-token-1' for details." |
24282 | 777 (or count (setq count 1)) |
778 (if (< count 0) | |
779 (- (c-forward-token-1 (- count) balanced lim)) | |
780 (let ((jump-syntax (if balanced | |
781 '(?w ?_ ?\( ?\) ?\" ?\\ ?/ ?$ ?') | |
782 '(?w ?_ ?\" ?\\ ?/ ?'))) | |
783 last) | |
784 (if (and (= count 0) | |
785 (or (and (memq (char-syntax (or (char-after) ? )) '(?w ?_)) | |
786 (memq (char-syntax (or (char-before) ? )) '(?w ?_))) | |
787 (/= (point) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
788 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
789 (c-forward-syntactic-ws (1+ lim)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
790 (point))) |
24282 | 791 (eobp))) |
792 ;; If count is zero we should jump if in the middle of a | |
793 ;; token or if there is whitespace between point and the | |
794 ;; following token beginning. | |
795 (setq count 1)) | |
796 (save-restriction | |
797 (if lim (narrow-to-region lim (point-max))) | |
798 (or (bobp) | |
799 (progn | |
36920 | 800 ;; Avoid having the limit tests inside the loop. |
24282 | 801 (condition-case nil |
802 (while (progn | |
803 (setq last (point)) | |
804 (> count 0)) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
805 (c-backward-syntactic-ws) |
24282 | 806 (if (memq (char-syntax (char-before)) jump-syntax) |
807 (goto-char (scan-sexps (point) -1)) | |
808 (backward-char)) | |
809 (setq count (1- count))) | |
810 (error (goto-char last))) | |
811 (if (bobp) (goto-char last))))) | |
812 count))) | |
21106
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
813 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
814 (defun c-syntactic-re-search-forward (regexp &optional bound noerror count |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
815 paren-level) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
816 ;; Like `re-search-forward', but only report matches that are found |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
817 ;; in syntactically significant text. I.e. matches that begins in |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
818 ;; comments, macros or string literals are ignored. The start point |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
819 ;; is assumed to be outside any comment, macro or string literal, or |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
820 ;; else the content of that region is taken as syntactically |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
821 ;; significant text. If PAREN-LEVEL is non-nil, an additional |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
822 ;; restriction is added to ignore matches in nested paren sexps, and |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
823 ;; the search will also not go outside the current paren sexp. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
824 (or bound (setq bound (point-max))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
825 (or count (setq count 1)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
826 (if paren-level (setq paren-level -1)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
827 (let ((start (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
828 (pos (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
829 match-pos state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
830 (condition-case err |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
831 (while (and (> count 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
832 (re-search-forward regexp bound noerror)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
833 (setq match-pos (point) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
834 state (parse-partial-sexp pos (match-beginning 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
835 paren-level nil state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
836 pos (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
837 (cond ((nth 3 state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
838 ;; Match inside a string. Skip to the end of it |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
839 ;; before continuing. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
840 (let ((ender (make-string 1 (nth 3 state)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
841 (while (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
842 (search-forward ender bound noerror) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
843 (setq state (parse-partial-sexp pos (point) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
844 nil nil state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
845 pos (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
846 (nth 3 state))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
847 ((nth 7 state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
848 ;; Match inside a line comment. Skip to eol. Use |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
849 ;; re-search-forward for it to get the right bound |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
850 ;; behavior. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
851 (re-search-forward "[\n\r]" bound noerror)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
852 ((nth 4 state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
853 ;; Match inside a block comment. Skip to the '*/'. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
854 (re-search-forward "\\*/" bound noerror)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
855 ((save-excursion (c-beginning-of-macro start)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
856 ;; Match inside a macro. Skip to the end of it. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
857 (c-end-of-macro)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
858 ((and paren-level (/= (car state) 0)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
859 (if (> (car state) 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
860 ;; Match inside a nested paren sexp. Skip out of it. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
861 (setq state (parse-partial-sexp pos bound 0 nil state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
862 pos (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
863 ;; Have exited the current paren sexp. The |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
864 ;; parse-partial-sexp above has left us just after |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
865 ;; the closing paren in this case. Just make |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
866 ;; re-search-forward above fail in the appropriate |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
867 ;; way; we'll adjust the leave off point below if |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
868 ;; necessary. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
869 (setq bound (point)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
870 (t |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
871 ;; A real match. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
872 (setq count (1- count))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
873 (error |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
874 (goto-char start) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
875 (signal (car err) (cdr err)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
876 (if (= count 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
877 (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
878 (goto-char match-pos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
879 match-pos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
880 ;; Search failed. Set point as appropriate. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
881 (cond ((eq noerror t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
882 (goto-char start)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
883 (paren-level |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
884 (if (eq (car (parse-partial-sexp pos bound -1 nil state)) -1) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
885 (backward-char))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
886 (t |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
887 (goto-char bound))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
888 nil))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
889 |
21106
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
890 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
891 (defun c-in-literal (&optional lim detect-cpp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
892 "Return the type of literal point is in, if any. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
893 The return value is `c' if in a C-style comment, `c++' if in a C++ |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
894 style comment, `string' if in a string literal, `pound' if DETECT-CPP |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
895 is non-nil and on a preprocessor line, or nil if somewhere else. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
896 Optional LIM is used as the backward limit of the search. If omitted, |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
897 or nil, `c-beginning-of-defun' is used. |
18720 | 898 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
899 The last point calculated is cached if the cache is enabled, i.e. if |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
900 `c-in-literal-cache' is bound to a two element vector." |
36920 | 901 (if (and (vectorp c-in-literal-cache) |
18720 | 902 (= (point) (aref c-in-literal-cache 0))) |
903 (aref c-in-literal-cache 1) | |
904 (let ((rtn (save-excursion | |
905 (let* ((lim (or lim (c-point 'bod))) | |
906 (state (parse-partial-sexp lim (point)))) | |
907 (cond | |
908 ((nth 3 state) 'string) | |
909 ((nth 4 state) (if (nth 7 state) 'c++ 'c)) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
910 ((and detect-cpp (c-beginning-of-macro lim)) 'pound) |
18720 | 911 (t nil)))))) |
912 ;; cache this result if the cache is enabled | |
36920 | 913 (if (not c-in-literal-cache) |
914 (setq c-in-literal-cache (vector (point) rtn))) | |
18720 | 915 rtn))) |
916 | |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
917 ;; 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
|
918 ;; I don't think we even need the cache, which makes our lives more |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
919 ;; complicated anyway. In this case, lim is only used to detect |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
920 ;; cpp directives. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
921 (defun c-fast-in-literal (&optional lim detect-cpp) |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
922 (let ((context (buffer-syntactic-context))) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
923 (cond |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
924 ((eq context 'string) 'string) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
925 ((eq context 'comment) 'c++) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
926 ((eq context 'block-comment) 'c) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
927 ((and detect-cpp (save-excursion (c-beginning-of-macro lim))) 'pound)))) |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
928 |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
929 (if (fboundp 'buffer-syntactic-context) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
930 (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
|
931 |
26817 | 932 (defun c-literal-limits (&optional lim near not-in-delimiter) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
933 "Return a cons of the beginning and end positions of the comment or |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
934 string surrounding point (including both delimiters), or nil if point |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
935 isn't in one. If LIM is non-nil, it's used as the \"safe\" position |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
936 to start parsing from. If NEAR is non-nil, then the limits of any |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
937 literal next to point is returned. \"Next to\" means there's only [ |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
938 \t] between point and the literal. The search for such a literal is |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
939 done first in forward direction. If NOT-IN-DELIMITER is non-nil, the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
940 case when point is inside a starting delimiter won't be recognized. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
941 This only has effect for comments, which have starting delimiters with |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
942 more than one character." |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
943 (save-excursion |
24282 | 944 (let* ((pos (point)) |
945 (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
|
946 (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
|
947 (cond ((nth 3 state) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
948 ;; 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
|
949 (while (nth 3 state) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
950 (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
|
951 (setq state (parse-partial-sexp lim (point)))) |
24282 | 952 (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
|
953 (point-max)))) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
954 ((nth 7 state) |
24282 | 955 ;; 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
|
956 (beginning-of-line) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
957 (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
|
958 lim (point)) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
959 (while (not (nth 7 state)) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
960 (search-forward "//") ; Should never fail. |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
961 (setq state (parse-partial-sexp |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
962 lim (point) nil nil state) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
963 lim (point))) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
964 (backward-char 2) |
26817 | 965 (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
|
966 ((nth 4 state) |
24282 | 967 ;; 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
|
968 (while (nth 4 state) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
969 (search-backward "/*") ; Should never fail. |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
970 (setq state (parse-partial-sexp lim (point)))) |
26817 | 971 (cons (point) (progn (c-forward-comment 1) (point)))) |
972 ((and (not not-in-delimiter) | |
973 (not (nth 5 state)) | |
974 (eq (char-before) ?/) | |
975 (looking-at "[/*]")) | |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
976 ;; We're standing in a comment starter. |
26817 | 977 (backward-char 1) |
978 (cons (point) (progn (c-forward-comment 1) (point)))) | |
24282 | 979 (near |
980 (goto-char pos) | |
981 ;; Search forward for a literal. | |
982 (skip-chars-forward " \t") | |
983 (cond | |
984 ((eq (char-syntax (or (char-after) ?\ )) ?\") ; String. | |
985 (cons (point) (or (c-safe (c-forward-sexp 1) (point)) | |
986 (point-max)))) | |
987 ((looking-at "/[/*]") ; Line or block comment. | |
26817 | 988 (cons (point) (progn (c-forward-comment 1) (point)))) |
24282 | 989 (t |
990 ;; Search backward. | |
991 (skip-chars-backward " \t") | |
992 (let ((end (point)) beg) | |
993 (cond | |
994 ((eq (char-syntax (or (char-before) ?\ )) ?\") ; String. | |
995 (setq beg (c-safe (c-backward-sexp 1) (point)))) | |
996 ((and (c-safe (forward-char -2) t) | |
997 (looking-at "*/")) | |
998 ;; Block comment. Due to the nature of line | |
999 ;; comments, they will always be covered by the | |
1000 ;; normal case above. | |
1001 (goto-char end) | |
26817 | 1002 (c-forward-comment -1) |
24282 | 1003 ;; If LIM is bogus, beg will be bogus. |
1004 (setq beg (point)))) | |
1005 (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
|
1006 )))) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
1007 |
26817 | 1008 (defun c-literal-limits-fast (&optional lim near not-in-delimiter) |
24282 | 1009 ;; Like c-literal-limits, but for emacsen whose `parse-partial-sexp' |
26817 | 1010 ;; 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
|
1011 (save-excursion |
26817 | 1012 (let* ((pos (point)) |
1013 (lim (or lim (c-point 'bod))) | |
1014 (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
|
1015 (cond ((nth 3 state) ; String. |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
1016 (goto-char (nth 8 state)) |
24282 | 1017 (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
|
1018 (point-max)))) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
1019 ((nth 4 state) ; Comment. |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
1020 (goto-char (nth 8 state)) |
26817 | 1021 (cons (point) (progn (c-forward-comment 1) (point)))) |
1022 ((and (not not-in-delimiter) | |
1023 (not (nth 5 state)) | |
1024 (eq (char-before) ?/) | |
1025 (looking-at "[/*]")) | |
1026 ;; We're standing in a comment starter. | |
1027 (backward-char 1) | |
1028 (cons (point) (progn (c-forward-comment 1) (point)))) | |
1029 (near | |
1030 (goto-char pos) | |
1031 ;; Search forward for a literal. | |
1032 (skip-chars-forward " \t") | |
1033 (cond | |
1034 ((eq (char-syntax (or (char-after) ?\ )) ?\") ; String. | |
1035 (cons (point) (or (c-safe (c-forward-sexp 1) (point)) | |
1036 (point-max)))) | |
1037 ((looking-at "/[/*]") ; Line or block comment. | |
1038 (cons (point) (progn (c-forward-comment 1) (point)))) | |
1039 (t | |
1040 ;; Search backward. | |
1041 (skip-chars-backward " \t") | |
1042 (let ((end (point)) beg) | |
1043 (cond | |
1044 ((eq (char-syntax (or (char-before) ?\ )) ?\") ; String. | |
1045 (setq beg (c-safe (c-backward-sexp 1) (point)))) | |
1046 ((and (c-safe (forward-char -2) t) | |
1047 (looking-at "*/")) | |
1048 ;; Block comment. Due to the nature of line | |
1049 ;; comments, they will always be covered by the | |
1050 ;; normal case above. | |
1051 (goto-char end) | |
1052 (c-forward-comment -1) | |
1053 ;; If LIM is bogus, beg will be bogus. | |
1054 (setq beg (point)))) | |
1055 (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
|
1056 )))) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
1057 |
26817 | 1058 (if (c-safe (> (length (save-excursion (parse-partial-sexp 1 1))) 8)) |
1059 (defalias 'c-literal-limits 'c-literal-limits-fast)) | |
1060 | |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
1061 (defun c-collect-line-comments (range) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1062 "If the argument is a cons of two buffer positions (such as returned by |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1063 `c-literal-limits'), and that range contains a C++ style line comment, |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1064 then an extended range is returned that contains all adjacent line |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1065 comments (i.e. all comments that starts in the same column with no |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1066 empty lines or non-whitespace characters between them). Otherwise the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1067 argument is returned." |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
1068 (save-excursion |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
1069 (condition-case nil |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
1070 (if (and (consp range) (progn |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
1071 (goto-char (car range)) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
1072 (looking-at "//"))) |
21106
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
1073 (let ((col (current-column)) |
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
1074 (beg (point)) |
36920 | 1075 (bopl (c-point 'bopl)) |
21106
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
1076 (end (cdr range))) |
36920 | 1077 ;; Got to take care in the backward direction to handle |
1078 ;; comments which are preceded by code. | |
26817 | 1079 (while (and (c-forward-comment -1) |
36920 | 1080 (>= (point) bopl) |
21106
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
1081 (looking-at "//") |
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
1082 (= col (current-column))) |
36920 | 1083 (setq beg (point) |
1084 bopl (c-point 'bopl))) | |
21106
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
1085 (goto-char end) |
26817 | 1086 (while (and (progn (skip-chars-forward " \t") |
1087 (looking-at "//")) | |
1088 (= col (current-column)) | |
1089 (prog1 (zerop (forward-line 1)) | |
1090 (setq end (point))))) | |
21106
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
1091 (cons beg end)) |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
1092 range) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
1093 (error range)))) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
1094 |
24282 | 1095 (defun c-literal-type (range) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1096 "Convenience function that given the result of `c-literal-limits', |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1097 returns nil or the type of literal that the range surrounds. It's |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1098 much faster than using `c-in-literal' and is intended to be used when |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1099 you need both the type of a literal and its limits." |
24282 | 1100 (if (consp range) |
26817 | 1101 (save-excursion |
1102 (goto-char (car range)) | |
1103 (cond ((eq (char-syntax (or (char-after) ?\ )) ?\") 'string) | |
1104 ((looking-at "//") 'c++) | |
1105 (t 'c))) ; Assuming the range is valid. | |
24282 | 1106 range)) |
1107 | |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
1108 |
18720 | 1109 |
1110 ;; utilities for moving and querying around syntactic elements | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1111 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1112 (defvar c-state-cache nil) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1113 (make-variable-buffer-local 'c-state-cache) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1114 ;; The state cache used by `c-parse-state' to cut down the amount of |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1115 ;; searching. It's the result from some earlier `c-parse-state' call. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1116 ;; The use of the cached info is more effective if the next |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1117 ;; `c-parse-state' call is on a line close by the one the cached state |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1118 ;; was made at; the cache can actually slow down a little if the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1119 ;; cached state was made very far back in the buffer. The cache is |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1120 ;; most effective if `c-parse-state' is used on each line while moving |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1121 ;; forward. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1122 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1123 (defvar c-state-cache-start nil) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1124 ;; This (point-min) when `c-state-cache' was calculated, to detect |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1125 ;; that the start point hasn't changed due to narrowing. |
18720 | 1126 |
1127 (defun c-parse-state () | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1128 ;; Finds and records all noteworthy parens between some good point |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1129 ;; earlier in the file and point. That good point is at least the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1130 ;; beginning of the top-level construct we are in, or the beginning |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1131 ;; of the preceding top-level construct if we aren't in one. |
18720 | 1132 ;; |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1133 ;; The returned value is a list of the noteworthy parens with the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1134 ;; last one first. If an element in the list is an integer, it's |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1135 ;; the position of an open paren which has not been closed before |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1136 ;; point. If an element is a cons, it gives the position of a |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1137 ;; closed brace paren pair; the car is the start paren position and |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1138 ;; the cdr is the position following the closing paren. Only the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1139 ;; last closed brace paren pair before each open paren is recorded, |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1140 ;; and thus the state never contains two cons elements in |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1141 ;; succession. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1142 (save-restriction |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1143 (let* ((here (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1144 (c-macro-start (c-query-macro-start)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1145 (in-macro-start (or c-macro-start (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1146 old-state last-pos pairs pos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1147 ;; Somewhat ugly use of c-check-state-cache to get rid of the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1148 ;; part of the state cache that is after point. Can't use |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1149 ;; c-whack-state-after for the same reasons as in that function. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1150 (c-check-state-cache (point) nil nil) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1151 ;; Get the latest position we know are directly inside the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1152 ;; closest containing paren of the cached state. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1153 (setq last-pos (and c-state-cache |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1154 (if (consp (car c-state-cache)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1155 (cdr (car c-state-cache)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1156 (1+ (car c-state-cache))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1157 ;; Check if the found last-pos is in a macro. If it is, and |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1158 ;; we're not in the same macro, we must discard everything on |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1159 ;; c-state-cache that is inside the macro before using it. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1160 (when last-pos |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1161 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1162 (goto-char last-pos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1163 (when (and (c-beginning-of-macro) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1164 (/= (point) in-macro-start)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1165 (c-check-state-cache (point) nil nil) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1166 ;; Set last-pos again, just like above. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1167 (setq last-pos (and c-state-cache |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1168 (if (consp (car c-state-cache)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1169 (cdr (car c-state-cache)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1170 (1+ (car c-state-cache)))))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1171 (setq pos |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1172 ;; Find the start position for the forward search. (Can't |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1173 ;; search in the backward direction since point might be |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1174 ;; in some kind of literal.) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1175 (or (when last-pos |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1176 ;; There's a cached state with a containing paren. Pop |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1177 ;; off the stale containing sexps from it by going |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1178 ;; forward out of parens as far as possible. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1179 (narrow-to-region (point-min) here) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1180 (let (placeholder pair-beg) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1181 (while (and c-state-cache |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1182 (setq placeholder |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1183 (c-up-list-forward last-pos))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1184 (setq last-pos placeholder) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1185 (if (consp (car c-state-cache)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1186 (setq pair-beg (car-safe (cdr c-state-cache)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1187 c-state-cache (cdr-safe (cdr c-state-cache))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1188 (setq pair-beg (car c-state-cache) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1189 c-state-cache (cdr c-state-cache)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1190 (when (and pair-beg (eq (char-after pair-beg) ?{)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1191 ;; The last paren pair we moved out from was a brace |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1192 ;; pair. Modify the state to record this as a closed |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1193 ;; pair now. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1194 (if (consp (car-safe c-state-cache)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1195 (setq c-state-cache (cdr c-state-cache))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1196 (setq c-state-cache (cons (cons pair-beg last-pos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1197 c-state-cache)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1198 ;; Check if the preceding balanced paren is within a |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1199 ;; macro; it should be ignored if we're outside the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1200 ;; macro. There's no need to check any further upwards; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1201 ;; if the macro contains an unbalanced opening paren then |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1202 ;; we're smoked anyway. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1203 (when (and (<= (point) in-macro-start) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1204 (consp (car c-state-cache))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1205 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1206 (goto-char (car (car c-state-cache))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1207 (when (c-beginning-of-macro) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1208 (setq here (point) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1209 c-state-cache (cdr c-state-cache))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1210 (when c-state-cache |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1211 (setq old-state c-state-cache) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1212 last-pos)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1213 (save-excursion |
18720 | 1214 ;; go back 2 bods, but ignore any bogus positions |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1215 ;; returned by beginning-of-defun (i.e. open paren in |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1216 ;; column zero) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1217 (goto-char here) |
18720 | 1218 (let ((cnt 2)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1219 (while (not (or (bobp) (zerop cnt))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1220 (c-beginning-of-defun-1) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1221 (if (eq (char-after) ?\{) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1222 (setq cnt (1- cnt))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1223 (point)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1224 (narrow-to-region (point-min) here) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1225 (while pos |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1226 ;; Find the balanced brace pairs. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1227 (setq pairs nil) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1228 (while (and (setq last-pos (c-down-list-forward pos)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1229 (setq pos (c-up-list-forward last-pos))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1230 (if (eq (char-before last-pos) ?{) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1231 (setq pairs (cons (cons last-pos pos) pairs)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1232 ;; Should ignore any pairs that are in a macro, providing |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1233 ;; we're not in the same one. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1234 (when (and pairs (< (car (car pairs)) in-macro-start)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1235 (while (and (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1236 (goto-char (car (car pairs))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1237 (c-beginning-of-macro)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1238 (setq pairs (cdr pairs))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1239 ;; Record the last brace pair. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1240 (when pairs |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1241 (if (and (eq c-state-cache old-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1242 (consp (car-safe c-state-cache))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1243 ;; There's a closed pair on the cached state but we've |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1244 ;; found a later one, so remove it. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1245 (setq c-state-cache (cdr c-state-cache))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1246 (setq pairs (car pairs)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1247 (setcar pairs (1- (car pairs))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1248 (setq c-state-cache (cons pairs c-state-cache))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1249 (if last-pos |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1250 ;; Prepare to loop, but record the open paren only if it's |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1251 ;; outside a macro or within the same macro as point. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1252 (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1253 (setq pos last-pos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1254 (if (or (>= last-pos in-macro-start) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1255 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1256 (goto-char last-pos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1257 (not (c-beginning-of-macro)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1258 (setq c-state-cache (cons (1- pos) c-state-cache)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1259 (if (setq last-pos (c-up-list-forward pos)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1260 ;; Found a close paren without a corresponding opening |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1261 ;; one. Maybe we didn't go back far enough, so try to |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1262 ;; scan backward for the start paren and then start over. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1263 (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1264 (setq pos (c-up-list-backward pos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1265 c-state-cache nil) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1266 (unless pos |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1267 (setq pos last-pos |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1268 c-parsing-error |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1269 (format "Unbalanced close paren at line %d" |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1270 (1+ (count-lines (point-min) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1271 (c-point 'bol last-pos))))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1272 (setq pos nil)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1273 c-state-cache))) |
18720 | 1274 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1275 ;; Debug tool to catch cache inconsistencies. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1276 (defvar c-debug-parse-state nil) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1277 (unless (fboundp 'c-real-parse-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1278 (fset 'c-real-parse-state (symbol-function 'c-parse-state))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1279 (cc-bytecomp-defun c-real-parse-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1280 (defun c-debug-parse-state () |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1281 (let ((res1 (c-real-parse-state)) res2) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1282 (let ((c-state-cache nil)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1283 (setq res2 (c-real-parse-state))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1284 (unless (equal res1 res2) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1285 (error "c-parse-state inconsistency: using cache: %s, from scratch: %s" |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1286 res1 res2)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1287 res1)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1288 (defun c-toggle-parse-state-debug (&optional arg) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1289 (interactive "P") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1290 (setq c-debug-parse-state (c-calculate-state arg c-debug-parse-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1291 (fset 'c-parse-state (symbol-function (if c-debug-parse-state |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1292 'c-debug-parse-state |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1293 'c-real-parse-state))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1294 (c-keep-region-active)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1295 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1296 (defun c-check-state-cache (beg end old-length) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1297 ;; Used on `after-change-functions' to adjust `c-state-cache'. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1298 ;; Prefer speed to finesse here, since there will be many more calls |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1299 ;; to this function than times `c-state-cache' is used. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1300 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1301 ;; This is much like `c-whack-state-after', but it never changes a |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1302 ;; paren pair element into an open paren element. Doing that would |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1303 ;; mean that the new open paren wouldn't have the required preceding |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1304 ;; paren pair element. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1305 (if (not (eq c-state-cache-start (point-min))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1306 (setq c-state-cache-start (point-min) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1307 c-state-cache nil) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1308 (while (and c-state-cache |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1309 (let ((elem (car c-state-cache))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1310 (if (consp elem) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1311 (or (<= beg (car elem)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1312 (< beg (cdr elem))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1313 (<= beg elem)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1314 (setq c-state-cache (cdr c-state-cache))))) |
18720 | 1315 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1316 (defun c-whack-state-before (bufpos paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1317 ;; Whack off any state information from PAREN-STATE which lies |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1318 ;; before BUFPOS. Not destructive on PAREN-STATE. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1319 (let* ((newstate (list nil)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1320 (ptr newstate) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1321 car) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1322 (while paren-state |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1323 (setq car (car paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1324 paren-state (cdr paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1325 (if (< (if (consp car) (car car) car) bufpos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1326 (setq paren-state nil) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1327 (setcdr ptr (list car)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1328 (setq ptr (cdr ptr)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1329 (cdr newstate))) |
18720 | 1330 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1331 (defun c-whack-state-after (bufpos paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1332 ;; Whack off any state information from PAREN-STATE which lies at or |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1333 ;; after BUFPOS. Not destructive on PAREN-STATE. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1334 (catch 'done |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1335 (while paren-state |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1336 (let ((car (car paren-state))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1337 (if (consp car) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1338 ;; just check the car, because in a balanced brace |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1339 ;; expression, it must be impossible for the corresponding |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1340 ;; close brace to be before point, but the open brace to |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1341 ;; be after. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1342 (if (<= bufpos (car car)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1343 nil ; whack it off |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1344 (if (< bufpos (cdr car)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1345 ;; its possible that the open brace is before |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1346 ;; bufpos, but the close brace is after. In that |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1347 ;; case, convert this to a non-cons element. The |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1348 ;; rest of the state is before bufpos, so we're |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1349 ;; done. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1350 (throw 'done (cons (car car) (cdr paren-state))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1351 ;; we know that both the open and close braces are |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1352 ;; before bufpos, so we also know that everything else |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1353 ;; on state is before bufpos. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1354 (throw 'done paren-state))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1355 (if (<= bufpos car) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1356 nil ; whack it off |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1357 ;; it's before bufpos, so everything else should too. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1358 (throw 'done paren-state))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1359 (setq paren-state (cdr paren-state))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1360 nil))) |
18720 | 1361 |
1362 | |
1363 (defun c-beginning-of-inheritance-list (&optional lim) | |
1364 ;; Go to the first non-whitespace after the colon that starts a | |
1365 ;; multiple inheritance introduction. Optional LIM is the farthest | |
1366 ;; back we should search. | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1367 (let* ((lim (or lim (c-point 'bod)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1368 (c-with-syntax-table c++-template-syntax-table |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1369 (c-backward-token-1 0 t lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1370 (while (and (looking-at "[_a-zA-Z<,]") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1371 (= (c-backward-token-1 1 t lim) 0))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1372 (skip-chars-forward "^:")))) |
18720 | 1373 |
1374 (defun c-in-method-def-p () | |
1375 ;; Return nil if we aren't in a method definition, otherwise the | |
1376 ;; position of the initial [+-]. | |
1377 (save-excursion | |
1378 (beginning-of-line) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1379 (and c-opt-method-key |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1380 (looking-at c-opt-method-key) |
18720 | 1381 (point)) |
1382 )) | |
1383 | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1384 ;; Contributed by Kevin Ryde <user42@zip.com.au>. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1385 (defun c-in-gcc-asm-p () |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1386 ;; Return non-nil if point is within a gcc \"asm\" block. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1387 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1388 ;; This should be called with point inside an argument list. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1389 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1390 ;; Only one level of enclosing parentheses is considered, so for |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1391 ;; instance `nil' is returned when in a function call within an asm |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1392 ;; operand. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1393 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1394 (and c-opt-asm-stmt-key |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1395 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1396 (beginning-of-line) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1397 (backward-up-list 1) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1398 (c-beginning-of-statement-1 (point-min) nil t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1399 (looking-at c-opt-asm-stmt-key)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1400 |
24335
0c4688f9a396
Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents:
24282
diff
changeset
|
1401 (defun c-at-toplevel-p () |
0c4688f9a396
Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents:
24282
diff
changeset
|
1402 "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
|
1403 Being at the top-level means that point is either outside any |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1404 enclosing block (such function definition), or inside a class, |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1405 namespace or extern definition, but outside any method blocks. |
24335
0c4688f9a396
Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents:
24282
diff
changeset
|
1406 |
0c4688f9a396
Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents:
24282
diff
changeset
|
1407 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
|
1408 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
|
1409 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
|
1410 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
|
1411 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
|
1412 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
|
1413 brace." |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1414 (let ((paren-state (c-parse-state))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1415 (or (not (c-most-enclosing-brace paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1416 (c-search-uplist-for-classkey paren-state)))) |
24335
0c4688f9a396
Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents:
24282
diff
changeset
|
1417 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1418 (defun c-forward-to-cpp-define-body () |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1419 ;; Assuming point is at the "#" that introduces a preprocessor |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1420 ;; directive, it's moved forward to the start of the definition body |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1421 ;; if it's a "#define". Non-nil is returned in this case, in all |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1422 ;; other cases nil is returned and point isn't moved. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1423 (when (and (looking-at |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1424 (concat "#[ \t]*" |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1425 "define[ \t]+\\(\\sw\\|_\\)+\\(\([^\)]*\)\\)?" |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1426 "\\([ \t]\\|\\\\\n\\)*")) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1427 (not (= (match-end 0) (c-point 'eol)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1428 (goto-char (match-end 0)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1429 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1430 (defun c-just-after-func-arglist-p (&optional containing lim) |
18720 | 1431 ;; Return t if we are between a function's argument list closing |
1432 ;; paren and its opening brace. Note that the list close brace | |
1433 ;; could be followed by a "const" specifier or a member init hanging | |
1434 ;; colon. Optional CONTAINING is position of containing s-exp open | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1435 ;; brace. If not supplied, point is used as search start. LIM is |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1436 ;; used as bound for some backward buffer searches; the search might |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1437 ;; continue past it. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1438 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1439 ;; Note: This test is easily fooled. It only works reasonably well |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1440 ;; in the situations where `c-guess-basic-syntax' uses it. |
18720 | 1441 (save-excursion |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1442 (c-backward-syntactic-ws lim) |
18720 | 1443 (let ((checkpoint (or containing (point)))) |
1444 (goto-char checkpoint) | |
1445 ;; could be looking at const specifier | |
1446 (if (and (eq (char-before) ?t) | |
1447 (forward-word -1) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1448 (looking-at "\\<const\\>[^_]")) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1449 (c-backward-syntactic-ws lim) |
18720 | 1450 ;; otherwise, we could be looking at a hanging member init |
1451 ;; colon | |
1452 (goto-char checkpoint) | |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1453 (while (eq (char-before) ?,) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1454 ;; 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
|
1455 ;; line arglists |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1456 (forward-char -1) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1457 (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
|
1458 (if (eq (char-before) ?\)) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1459 (c-backward-sexp 2) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1460 (c-backward-sexp 1)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1461 (c-backward-syntactic-ws lim)) |
18720 | 1462 (if (and (eq (char-before) ?:) |
1463 (progn | |
1464 (forward-char -1) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1465 (c-backward-syntactic-ws lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1466 (looking-at "\\([ \t\n]\\|\\\\\n\\)*:\\([^:]+\\|$\\)"))) |
18720 | 1467 nil |
1468 (goto-char checkpoint)) | |
1469 ) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1470 (setq checkpoint (point)) |
18720 | 1471 (and (eq (char-before) ?\)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1472 ;; Check that it isn't a cpp expression, e.g. the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1473 ;; expression of an #if directive or the "function header" |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1474 ;; of a #define. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1475 (or (not (c-beginning-of-macro)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1476 (and (c-forward-to-cpp-define-body) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1477 (< (point) checkpoint))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1478 ;; check if we are looking at an ObjC method def |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1479 (or (not c-opt-method-key) |
18720 | 1480 (progn |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1481 (goto-char checkpoint) |
24282 | 1482 (c-forward-sexp -1) |
18720 | 1483 (forward-char -1) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1484 (c-backward-syntactic-ws lim) |
18720 | 1485 (not (or (memq (char-before) '(?- ?+)) |
1486 ;; or a class category | |
1487 (progn | |
24282 | 1488 (c-forward-sexp -2) |
18720 | 1489 (looking-at c-class-key)) |
1490 ))))) | |
1491 ))) | |
1492 | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1493 (defun c-in-knr-argdecl (&optional lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1494 ;; Return the position of the first argument declaration if point is |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1495 ;; inside a K&R style argument declaration list, nil otherwise. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1496 ;; `c-recognize-knr-p' is not checked. If LIM is non-nil, it's a |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1497 ;; position that bounds the backward search for the argument list. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1498 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1499 ;; Note: A declaration level context is assumed; the test can return |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1500 ;; false positives for statements and #define headers. This test is |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1501 ;; even more easily fooled than `c-just-after-func-arglist-p'. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1502 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1503 (save-restriction |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1504 ;; Go back to the closest preceding normal parenthesis sexp. We |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1505 ;; take that as the argument list in the function header. Then |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1506 ;; check that it's followed by some symbol before the next ';' |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1507 ;; or '{'. If it does, it's the header of the K&R argdecl we're |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1508 ;; in. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1509 (if lim (narrow-to-region lim (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1510 (let (paren-end) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1511 (and (c-safe (setq paren-end (c-down-list-backward (point)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1512 (eq (char-after paren-end) ?\)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1513 (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1514 (goto-char (1+ paren-end)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1515 (c-forward-syntactic-ws) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1516 (looking-at "\\w\\|\\s_")) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1517 (c-safe (c-up-list-backward paren-end)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1518 (point)))))) |
18720 | 1519 |
1520 (defun c-skip-conditional () | |
1521 ;; skip forward over conditional at point, including any predicate | |
1522 ;; statements in parentheses. No error checking is performed. | |
24282 | 1523 (c-forward-sexp (cond |
1524 ;; else if() | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1525 ((looking-at (concat "\\<else" |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1526 "\\([ \t\n]\\|\\\\\n\\)+" |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1527 "if\\>\\([^_]\\|$\\)")) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1528 3) |
24282 | 1529 ;; do, else, try, finally |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1530 ((looking-at (concat "\\<\\(" |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1531 "do\\|else\\|try\\|finally" |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1532 "\\)\\>\\([^_]\\|$\\)")) |
36920 | 1533 1) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1534 ;; for, if, while, switch, catch, synchronized, foreach |
24282 | 1535 (t 2)))) |
18720 | 1536 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1537 (defun c-after-conditional (&optional lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1538 ;; If looking at the token after a conditional then return the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1539 ;; position of its start, otherwise return nil. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1540 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1541 (and (= (c-backward-token-1 1 t lim) 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1542 (or (looking-at c-block-stmt-1-key) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1543 (and (eq (char-after) ?\() |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1544 (= (c-backward-token-1 1 t lim) 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1545 (looking-at c-block-stmt-2-key))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1546 (point)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1547 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1548 (defsubst c-backward-to-block-anchor (&optional lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1549 ;; Assuming point is at a brace that opens a statement block of some |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1550 ;; kind, move to the proper anchor point for that block. It might |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1551 ;; need to be adjusted further by c-add-stmt-syntax, but the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1552 ;; position at return is suitable as start position for that |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1553 ;; function. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1554 (unless (= (point) (c-point 'boi)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1555 (let ((start (c-after-conditional lim))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1556 (if start |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1557 (goto-char start))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1558 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1559 (defun c-backward-to-decl-anchor (&optional lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1560 ;; Assuming point is at a brace that opens the block of a top level |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1561 ;; declaration of some kind, move to the proper anchor point for |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1562 ;; that block. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1563 (unless (= (point) (c-point 'boi)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1564 ;; What we have below is actually an extremely stripped variant of |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1565 ;; c-beginning-of-statement-1. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1566 (let ((pos (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1567 ;; Switch syntax table to avoid stopping at line continuations. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1568 (save-restriction |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1569 (if lim (narrow-to-region lim (point-max))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1570 (while (and (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1571 (c-backward-syntactic-ws) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1572 (c-safe (goto-char (scan-sexps (point) -1)) t)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1573 (not (c-crosses-statement-barrier-p (point) pos))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1574 (setq pos (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1575 (goto-char pos))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1576 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1577 (defsubst c-search-decl-header-end () |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1578 ;; Search forward for the end of the "header" of the current |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1579 ;; declaration. That's the position where the definition body |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1580 ;; starts, or the first variable initializer, or the ending |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1581 ;; semicolon. I.e. search forward for the closest following |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1582 ;; (syntactically relevant) '{', '=' or ';' token. Point is left |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1583 ;; _after_ the first found token, or at point-max if none is found. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1584 (c-with-syntax-table (if (c-major-mode-is 'c++-mode) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1585 c++-template-syntax-table |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1586 (syntax-table)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1587 (while (and (c-syntactic-re-search-forward "[;{=]" nil 'move 1 t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1588 ;; In Pike it can be an operator identifier containing |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1589 ;; '='. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1590 (c-major-mode-is 'pike-mode) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1591 (eq (char-before) ?=) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1592 (c-on-identifier))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1593 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1594 (defun c-beginning-of-decl-1 (&optional lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1595 ;; Go to the beginning of the current declaration, or the beginning |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1596 ;; of the previous one if already at the start of it. Point won't |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1597 ;; be moved out of any surrounding paren. Return a cons cell on the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1598 ;; form (MOVE . KNR-POS). MOVE is like the return value from |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1599 ;; `c-beginning-of-statement-1'. If point skipped over some K&R |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1600 ;; style argument declarations (and they are to be recognized) then |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1601 ;; KNR-POS is set to the start of the first such argument |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1602 ;; declaration, otherwise KNR-POS is nil. If LIM is non-nil, it's a |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1603 ;; position that bounds the backward search. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1604 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1605 ;; NB: Cases where the declaration continues after the block, as in |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1606 ;; "struct foo { ... } bar;", are currently recognized as two |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1607 ;; declarations, e.g. "struct foo { ... }" and "bar;" in this case. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1608 (catch 'return |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1609 (let* ((start (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1610 (last-stmt-start (point)) |
45049
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1611 (move (c-beginning-of-statement-1 lim t t))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1612 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1613 (while (and (/= last-stmt-start (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1614 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1615 (c-backward-syntactic-ws lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1616 (not (memq (char-before) '(?\; ?} ?: nil))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1617 ;; `c-beginning-of-statement-1' stops at a block start, but we |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1618 ;; want to continue if the block doesn't begin a top level |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1619 ;; construct, i.e. if it isn't preceded by ';', '}', ':', or bob. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1620 (setq last-stmt-start (point) |
45049
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1621 move (c-beginning-of-statement-1 lim t t))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1622 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1623 (when c-recognize-knr-p |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1624 (let ((fallback-pos (point)) knr-argdecl-start) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1625 ;; Handle K&R argdecls. Back up after the "statement" jumped |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1626 ;; over by `c-beginning-of-statement-1', unless it was the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1627 ;; function body, in which case we're sitting on the opening |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1628 ;; brace now. Then test if we're in a K&R argdecl region and |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1629 ;; that we started at the other side of the first argdecl in |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1630 ;; it. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1631 (unless (eq (char-after) ?{) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1632 (goto-char last-stmt-start)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1633 (if (and (setq knr-argdecl-start (c-in-knr-argdecl lim)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1634 (< knr-argdecl-start start) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1635 (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1636 (goto-char knr-argdecl-start) |
45049
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1637 (not (eq (c-beginning-of-statement-1 lim t t) 'macro)))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1638 (throw 'return |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1639 (cons (if (eq (char-after fallback-pos) ?{) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1640 'previous |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1641 'same) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1642 knr-argdecl-start)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1643 (goto-char fallback-pos)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1644 |
45049
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1645 (when c-opt-access-key |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1646 ;; Might have ended up before a protection label. This should |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1647 ;; perhaps be checked before `c-recognize-knr-p' to be really |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1648 ;; accurate, but we know that no language has both. |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1649 (while (looking-at c-opt-access-key) |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1650 (goto-char (match-end 0)) |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1651 (c-forward-syntactic-ws) |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1652 (when (>= (point) start) |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1653 (goto-char start) |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1654 (throw 'return (cons 'same nil))))) |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1655 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1656 ;; `c-beginning-of-statement-1' counts each brace block as a |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1657 ;; separate statement, so the result will be 'previous if we've |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1658 ;; moved over any. If they were brace list initializers we might |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1659 ;; not have moved over a declaration boundary though, so change it |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1660 ;; to 'same if we've moved past a '=' before '{', but not ';'. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1661 ;; (This ought to be integrated into `c-beginning-of-statement-1', |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1662 ;; so we avoid this extra pass which potentially can search over a |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1663 ;; large amount of text.) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1664 (if (and (eq move 'previous) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1665 (c-with-syntax-table (if (c-major-mode-is 'c++-mode) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1666 c++-template-syntax-table |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1667 (syntax-table)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1668 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1669 (and (c-syntactic-re-search-forward "[;={]" start t 1 t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1670 (eq (char-before) ?=) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1671 (c-syntactic-re-search-forward "[;{]" start t 1 t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1672 (eq (char-before) ?{) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1673 (c-safe (goto-char (c-up-list-forward (point))) t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1674 (not (c-syntactic-re-search-forward ";" start t 1 t)))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1675 (cons 'same nil) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1676 (cons move nil))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1677 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1678 (defun c-end-of-decl-1 () |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1679 ;; Assuming point is at the start of a declaration (as detected by |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1680 ;; e.g. `c-beginning-of-decl-1'), go to the end of it. Unlike |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1681 ;; `c-beginning-of-decl-1', this function handles the case when a |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1682 ;; block is followed by identifiers in e.g. struct declarations in C |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1683 ;; or C++. If a proper end was found then t is returned, otherwise |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1684 ;; point is moved as far as possible within the current sexp and nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1685 ;; is returned. This function doesn't handle macros; use |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1686 ;; `c-end-of-macro' instead in those cases. |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1687 (let ((start (point)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1688 (decl-syntax-table (if (c-major-mode-is 'c++-mode) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1689 c++-template-syntax-table |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1690 (syntax-table)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1691 (catch 'return |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1692 (c-search-decl-header-end) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1693 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1694 (when (and c-recognize-knr-p |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1695 (eq (char-before) ?\;) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1696 (c-in-knr-argdecl start)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1697 ;; Stopped at the ';' in a K&R argdecl section which is |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1698 ;; detected using the same criteria as in |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1699 ;; `c-beginning-of-decl-1'. Move to the following block |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1700 ;; start. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1701 (c-syntactic-re-search-forward "{" nil 'move 1 t)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1702 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1703 (when (eq (char-before) ?{) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1704 ;; Encountered a block in the declaration. Jump over it. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1705 (condition-case nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1706 (goto-char (c-up-list-forward (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1707 (goto-char (point-max)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1708 (throw 'return nil)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1709 (if (or (not c-opt-block-decls-with-vars-key) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1710 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1711 (c-with-syntax-table decl-syntax-table |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1712 (let ((lim (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1713 (goto-char start) |
45049
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1714 (not (and |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1715 ;; Check for `c-opt-block-decls-with-vars-key' |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1716 ;; before the first paren. |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1717 (c-syntactic-re-search-forward |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1718 (concat "[;=\(\[{]\\|\\<\\(" |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1719 c-opt-block-decls-with-vars-key |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1720 "\\)") |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1721 lim t 1 t) |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1722 (match-beginning 1) |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1723 (not (eq (char-before) ?_)) |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1724 ;; Check that the first following paren is the block. |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1725 (c-syntactic-re-search-forward "[;=\(\[{]" lim t 1 t) |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
1726 (eq (char-before) ?{))))))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1727 ;; The declaration doesn't have any of the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1728 ;; `c-opt-block-decls-with-vars' keywords in the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1729 ;; beginning, so it ends here at the end of the block. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1730 (throw 'return t))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1731 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1732 (c-with-syntax-table decl-syntax-table |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1733 (while (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1734 (if (eq (char-before) ?\;) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1735 (throw 'return t)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1736 (c-syntactic-re-search-forward ";" nil 'move 1 t)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1737 nil))) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1738 |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1739 (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
|
1740 ;; 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
|
1741 ;; ':') 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
|
1742 (or limit |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1743 (setq limit (point-min))) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1744 (skip-chars-forward " \t") |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1745 (if (eq (char-after) ?,) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1746 (forward-char 1) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1747 (c-backward-syntactic-ws limit)) |
40261
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1748 (while (and (< limit (point)) |
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1749 (eq (char-before) ?,)) |
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1750 ;; this will catch member inits with multiple |
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1751 ;; line arglists |
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1752 (forward-char -1) |
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1753 (c-backward-syntactic-ws limit) |
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1754 (if (eq (char-before) ?\)) |
36920 | 1755 (c-backward-sexp 1)) |
40261
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1756 (c-backward-syntactic-ws limit) |
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1757 ;; Skip over any template arg to the class. |
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1758 (if (eq (char-before) ?>) |
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1759 (c-with-syntax-table c++-template-syntax-table |
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1760 (c-backward-sexp 1))) |
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1761 (c-backward-sexp 1) |
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1762 (c-backward-syntactic-ws limit) |
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1763 ;; Skip backwards over a fully::qualified::name. |
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1764 (while (and (eq (char-before) ?:) |
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1765 (save-excursion |
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1766 (forward-char -1) |
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1767 (eq (char-before) ?:))) |
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1768 (backward-char 2) |
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1769 (c-backward-sexp 1)) |
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1770 ;; now continue checking |
f921ca937b6d
(c-beginning-of-member-init-list):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
38422
diff
changeset
|
1771 (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
|
1772 (and (< limit (point)) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1773 (eq (char-before) ?:))) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
1774 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1775 (defun c-search-uplist-for-classkey (paren-state) |
18720 | 1776 ;; search for the containing class, returning a 2 element vector if |
24282 | 1777 ;; found. aref 0 contains the bufpos of the boi of the class key |
1778 ;; line, and aref 1 contains the bufpos of the open brace. | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1779 (if (null paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1780 ;; no paren-state means we cannot be inside a class |
18720 | 1781 nil |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1782 (let ((carcache (car paren-state)) |
18720 | 1783 search-start search-end) |
1784 (if (consp carcache) | |
1785 ;; a cons cell in the first element means that there is some | |
1786 ;; balanced sexp before the current bufpos. this we can | |
1787 ;; ignore. the nth 1 and nth 2 elements define for us the | |
1788 ;; search boundaries | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1789 (setq search-start (nth 2 paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1790 search-end (nth 1 paren-state)) |
18720 | 1791 ;; if the car was not a cons cell then nth 0 and nth 1 define |
1792 ;; for us the search boundaries | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1793 (setq search-start (nth 1 paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1794 search-end (nth 0 paren-state))) |
18720 | 1795 ;; if search-end is nil, or if the search-end character isn't an |
1796 ;; open brace, we are definitely not in a class | |
46688
07e19a2737a1
(c-search-uplist-for-classkey): When `search-end' is a cons, use its car.
Sam Steingold <sds@gnu.org>
parents:
45512
diff
changeset
|
1797 (when (consp search-end) |
07e19a2737a1
(c-search-uplist-for-classkey): When `search-end' is a cons, use its car.
Sam Steingold <sds@gnu.org>
parents:
45512
diff
changeset
|
1798 (setq search-end (car search-end))) |
07e19a2737a1
(c-search-uplist-for-classkey): When `search-end' is a cons, use its car.
Sam Steingold <sds@gnu.org>
parents:
45512
diff
changeset
|
1799 (unless (or (not search-end) |
07e19a2737a1
(c-search-uplist-for-classkey): When `search-end' is a cons, use its car.
Sam Steingold <sds@gnu.org>
parents:
45512
diff
changeset
|
1800 (< search-end (point-min)) |
07e19a2737a1
(c-search-uplist-for-classkey): When `search-end' is a cons, use its car.
Sam Steingold <sds@gnu.org>
parents:
45512
diff
changeset
|
1801 (not (eq (char-after search-end) ?{))) |
18720 | 1802 ;; now, we need to look more closely at search-start. if |
1803 ;; search-start is nil, then our start boundary is really | |
1804 ;; point-min. | |
1805 (if (not search-start) | |
1806 (setq search-start (point-min)) | |
1807 ;; if search-start is a cons cell, then we can start | |
1808 ;; searching from the end of the balanced sexp just ahead of | |
1809 ;; us | |
1810 (if (consp search-start) | |
1811 (setq search-start (cdr search-start)))) | |
1812 ;; now we can do a quick regexp search from search-start to | |
1813 ;; search-end and see if we can find a class key. watch for | |
1814 ;; class like strings in literals | |
1815 (save-excursion | |
1816 (save-restriction | |
1817 (goto-char search-start) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1818 (let (foundp class match-end) |
18720 | 1819 (while (and (not foundp) |
1820 (progn | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1821 (c-forward-syntactic-ws search-end) |
18720 | 1822 (> search-end (point))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1823 (re-search-forward c-decl-block-key search-end t)) |
18720 | 1824 (setq class (match-beginning 0) |
1825 match-end (match-end 0)) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1826 (goto-char class) |
18720 | 1827 (if (c-in-literal search-start) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1828 (goto-char match-end) ; its in a comment or string, ignore |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1829 (c-skip-ws-forward) |
18720 | 1830 (setq foundp (vector (c-point 'boi) search-end)) |
1831 (cond | |
1832 ;; check for embedded keywords | |
1833 ((let ((char (char-after (1- class)))) | |
1834 (and char | |
1835 (memq (char-syntax char) '(?w ?_)))) | |
1836 (goto-char match-end) | |
1837 (setq foundp nil)) | |
1838 ;; make sure we're really looking at the start of a | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1839 ;; class definition, and not an ObjC method. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1840 ((and c-opt-method-key |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1841 (re-search-forward c-opt-method-key search-end t) |
24282 | 1842 (not (c-in-literal class))) |
18720 | 1843 (setq foundp nil)) |
24282 | 1844 ;; Check if this is an anonymous inner class. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1845 ((and c-opt-inexpr-class-key |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1846 (looking-at c-opt-inexpr-class-key)) |
24282 | 1847 (while (and (= (c-forward-token-1 1 t) 0) |
1848 (looking-at "(\\|\\w\\|\\s_\\|\\."))) | |
1849 (if (eq (point) search-end) | |
1850 ;; We're done. Just trap this case in the cond. | |
1851 nil | |
1852 ;; False alarm; all conditions aren't satisfied. | |
1853 (setq foundp nil))) | |
18720 | 1854 ;; Its impossible to define a regexp for this, and |
1855 ;; nearly so to do it programmatically. | |
1856 ;; | |
1857 ;; ; picks up forward decls | |
1858 ;; = picks up init lists | |
1859 ;; ) picks up return types | |
1860 ;; > picks up templates, but remember that we can | |
1861 ;; inherit from templates! | |
1862 ((let ((skipchars "^;=)")) | |
1863 ;; try to see if we found the `class' keyword | |
1864 ;; inside a template arg list | |
1865 (save-excursion | |
1866 (skip-chars-backward "^<>" search-start) | |
1867 (if (eq (char-before) ?<) | |
1868 (setq skipchars (concat skipchars ">")))) | |
24282 | 1869 (while (progn |
1870 (skip-chars-forward skipchars search-end) | |
1871 (c-in-literal class)) | |
1872 (forward-char)) | |
18720 | 1873 (/= (point) search-end)) |
1874 (setq foundp nil)) | |
1875 ))) | |
1876 foundp)) | |
1877 ))))) | |
1878 | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1879 (defun c-inside-bracelist-p (containing-sexp paren-state) |
18720 | 1880 ;; return the buffer position of the beginning of the brace list |
1881 ;; statement if we're inside a brace list, otherwise return nil. | |
1882 ;; CONTAINING-SEXP is the buffer pos of the innermost containing | |
36920 | 1883 ;; paren. BRACE-STATE is the remainder of the state of enclosing |
1884 ;; braces | |
18720 | 1885 ;; |
1886 ;; N.B.: This algorithm can potentially get confused by cpp macros | |
1887 ;; places in inconvenient locations. Its a trade-off we make for | |
1888 ;; speed. | |
1889 (or | |
1890 ;; 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
|
1891 (c-safe |
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
1892 (save-excursion |
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
1893 (goto-char containing-sexp) |
24282 | 1894 (c-forward-sexp -1) |
21106
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
1895 (let (bracepos) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1896 (if (and (or (looking-at "enum\\>[^_]") |
24282 | 1897 (progn (c-forward-sexp -1) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1898 (looking-at "enum\\>[^_]"))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1899 (setq bracepos (c-down-list-forward (point))) |
21106
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
1900 (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
|
1901 (- bracepos 2)))) |
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
1902 (point))))) |
18720 | 1903 ;; this will pick up array/aggregate init lists, even if they are nested. |
1904 (save-excursion | |
24282 | 1905 (let ((class-key |
1906 ;; Pike can have class definitions anywhere, so we must | |
1907 ;; check for the class key here. | |
1908 (and (c-major-mode-is 'pike-mode) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1909 c-decl-block-key)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1910 bufpos braceassignp lim next-containing) |
18720 | 1911 (while (and (not bufpos) |
1912 containing-sexp) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1913 (when paren-state |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1914 (if (consp (car paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1915 (setq lim (cdr (car paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1916 paren-state (cdr paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1917 (setq lim (car paren-state))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1918 (when paren-state |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1919 (setq next-containing (car paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1920 paren-state (cdr paren-state)))) |
18720 | 1921 (goto-char containing-sexp) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1922 (if (c-looking-at-inexpr-block next-containing next-containing) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1923 ;; We're in an in-expression block of some kind. Do not |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1924 ;; check nesting. We deliberately set the limit to the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1925 ;; containing sexp, so that c-looking-at-inexpr-block |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1926 ;; doesn't check for an identifier before it. |
24282 | 1927 (setq containing-sexp nil) |
1928 ;; see if the open brace is preceded by = or [...] in | |
1929 ;; this statement, but watch out for operator= | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1930 (setq braceassignp 'dontknow) |
25178
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
1931 (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
|
1932 ;; 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
|
1933 (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
|
1934 (eq (char-after) ?\[)) |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
1935 ;; 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
|
1936 ;; 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
|
1937 ;; earlier. |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
1938 (while (eq braceassignp 'dontknow) |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
1939 (setq braceassignp |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
1940 (cond ((/= (c-backward-token-1 1 t lim) 0) nil) |
36920 | 1941 ((looking-at "new\\>[^_]") t) |
25178
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
1942 ((looking-at "\\sw\\|\\s_\\|[.[]") |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
1943 ;; 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
|
1944 ;; identifier (may contain "." in Java) |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
1945 ;; or another "[]" sexp. |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
1946 'dontknow) |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
1947 (t nil))))) |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
1948 ;; 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
|
1949 ;; beginning of the statement. |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
1950 (while (eq braceassignp 'dontknow) |
24282 | 1951 (cond ((eq (char-after) ?\;) |
1952 (setq braceassignp nil)) | |
1953 ((and class-key | |
1954 (looking-at class-key)) | |
1955 (setq braceassignp nil)) | |
1956 ((eq (char-after) ?=) | |
1957 ;; We've seen a =, but must check earlier tokens so | |
1958 ;; that it isn't something that should be ignored. | |
1959 (setq braceassignp 'maybe) | |
1960 (while (and (eq braceassignp 'maybe) | |
1961 (zerop (c-backward-token-1 1 t lim))) | |
1962 (setq braceassignp | |
1963 (cond | |
1964 ;; Check for operator = | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1965 ((looking-at "operator\\>[^_]") nil) |
36920 | 1966 ;; Check for `<opchar>= in Pike. |
1967 ((and (c-major-mode-is 'pike-mode) | |
1968 (or (eq (char-after) ?`) | |
1969 ;; Special case for Pikes | |
1970 ;; `[]=, since '[' is not in | |
1971 ;; the punctuation class. | |
1972 (and (eq (char-after) ?\[) | |
1973 (eq (char-before) ?`)))) | |
1974 nil) | |
24282 | 1975 ((looking-at "\\s.") 'maybe) |
1976 ;; make sure we're not in a C++ template | |
1977 ;; argument assignment | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1978 ((and |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1979 (c-major-mode-is 'c++-mode) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1980 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1981 (let ((here (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1982 (pos< (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1983 (skip-chars-backward "^<>") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1984 (point)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1985 (and (eq (char-before) ?<) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1986 (not (c-crosses-statement-barrier-p |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1987 pos< here)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1988 (not (c-in-literal)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1989 )))) |
24282 | 1990 nil) |
25178
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
1991 (t t)))))) |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
1992 (if (and (eq braceassignp 'dontknow) |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
1993 (/= (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
|
1994 (setq braceassignp nil))) |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
1995 (if (not braceassignp) |
24282 | 1996 (if (eq (char-after) ?\;) |
1997 ;; Brace lists can't contain a semicolon, so we're done. | |
1998 (setq containing-sexp nil) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1999 ;; Go up one level. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2000 (setq containing-sexp next-containing |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2001 lim nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2002 next-containing nil)) |
24282 | 2003 ;; we've hit the beginning of the aggregate list |
2004 (c-beginning-of-statement-1 | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2005 (c-most-enclosing-brace paren-state)) |
24282 | 2006 (setq bufpos (point)))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2007 ) |
18720 | 2008 bufpos)) |
2009 )) | |
2010 | |
24282 | 2011 (defun c-looking-at-special-brace-list (&optional lim) |
2012 ;; 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
|
2013 ;; `([ ])', `(< >)' etc, a cons of a cons of its starting and ending |
24282 | 2014 ;; positions and its entry in c-special-brace-lists is returned, nil |
2015 ;; otherwise. The ending position is nil if the list is still open. | |
2016 ;; LIM is the limit for forward search. The point may either be at | |
2017 ;; the `(' or at the following paren character. Tries to check the | |
2018 ;; matching closer, but assumes it's correct if no balanced paren is | |
2019 ;; found (i.e. the case `({ ... } ... )' is detected as _not_ being | |
2020 ;; a special brace list). | |
2021 (if c-special-brace-lists | |
2022 (condition-case () | |
2023 (save-excursion | |
2024 (let ((beg (point)) | |
2025 end type) | |
2026 (c-forward-syntactic-ws) | |
2027 (if (eq (char-after) ?\() | |
2028 (progn | |
2029 (forward-char 1) | |
2030 (c-forward-syntactic-ws) | |
2031 (setq type (assq (char-after) c-special-brace-lists))) | |
2032 (if (setq type (assq (char-after) c-special-brace-lists)) | |
2033 (progn | |
2034 (c-backward-syntactic-ws) | |
2035 (forward-char -1) | |
2036 (setq beg (if (eq (char-after) ?\() | |
2037 (point) | |
2038 nil))))) | |
2039 (if (and beg type) | |
2040 (if (and (c-safe (goto-char beg) | |
2041 (c-forward-sexp 1) | |
2042 (setq end (point)) | |
2043 (= (char-before) ?\))) | |
2044 (c-safe (goto-char beg) | |
2045 (forward-char 1) | |
2046 (c-forward-sexp 1) | |
2047 ;; Kludges needed to handle inner | |
2048 ;; chars both with and without | |
2049 ;; paren syntax. | |
2050 (or (/= (char-syntax (char-before)) ?\)) | |
2051 (= (char-before) (cdr type))))) | |
2052 (if (or (/= (char-syntax (char-before)) ?\)) | |
2053 (= (progn | |
2054 (c-forward-syntactic-ws) | |
2055 (point)) | |
2056 (1- end))) | |
2057 (cons (cons beg end) type)) | |
2058 (cons (list beg) type))))) | |
2059 (error nil)))) | |
2060 | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2061 (defun c-looking-at-bos (&optional lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2062 ;; Return non-nil if between two statements or declarations, assuming |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2063 ;; point is not inside a literal or comment. |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
2064 (save-excursion |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2065 (c-backward-syntactic-ws lim) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
2066 (or (bobp) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2067 ;; Return t if at the start inside some parenthesis expression |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2068 ;; too, to catch macros that have statements as arguments. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2069 (memq (char-before) '(?\; ?} ?\()) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
2070 (and (eq (char-before) ?{) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
2071 (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
|
2072 (progn (backward-char) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
2073 (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
|
2074 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2075 (defun c-looking-at-inexpr-block (lim containing-sexp) |
24282 | 2076 ;; Returns non-nil if we're looking at the beginning of a block |
2077 ;; inside an expression. The value returned is actually a cons of | |
2078 ;; either 'inlambda, 'inexpr-statement or 'inexpr-class and the | |
2079 ;; position of the beginning of the construct. LIM limits the | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2080 ;; backward search. CONTAINING-SEXP is the start position of the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2081 ;; closest containing list. If it's nil, the containing paren isn't |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2082 ;; used to decide whether we're inside an expression or not. If |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2083 ;; both LIM and CONTAINING-SEXP is used, LIM needs to be farther |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2084 ;; back. |
24282 | 2085 (save-excursion |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2086 (let ((res 'maybe) passed-bracket |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2087 (closest-lim (or containing-sexp lim (point-min))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2088 ;; Look at the character after point only as a last resort |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2089 ;; when we can't disambiguate. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2090 (block-follows (and (eq (char-after) ?{) (point)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2091 (while (and (eq res 'maybe) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2092 (progn (c-backward-syntactic-ws) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2093 (> (point) closest-lim)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2094 (not (bobp)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2095 (progn (backward-char) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2096 (looking-at "[\]\).]\\|\\w\\|\\s_")) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2097 (progn (forward-char) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2098 (goto-char (scan-sexps (point) -1)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2099 (setq res |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2100 (cond |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2101 ((and block-follows |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2102 c-opt-inexpr-class-key |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2103 (looking-at c-opt-inexpr-class-key)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2104 (and (not passed-bracket) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2105 (or (not (looking-at c-class-key)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2106 ;; If the class definition is at the start of |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2107 ;; a statement, we don't consider it an |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2108 ;; in-expression class. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2109 (let ((prev (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2110 (while (and |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2111 (= (c-backward-token-1 1 nil closest-lim) 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2112 (eq (char-syntax (char-after)) ?w)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2113 (setq prev (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2114 (goto-char prev) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2115 (not (c-looking-at-bos))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2116 ;; Also, in Pike we treat it as an |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2117 ;; in-expression class if it's used in an |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2118 ;; object clone expression. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2119 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2120 (and (c-major-mode-is 'pike-mode) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2121 (progn (goto-char block-follows) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2122 (= (c-forward-token-1 1 t) 0)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2123 (eq (char-after) ?\()))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2124 (cons 'inexpr-class (point)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2125 ((and c-opt-inexpr-block-key |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2126 (looking-at c-opt-inexpr-block-key)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2127 (cons 'inexpr-statement (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2128 ((and c-opt-lambda-key |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2129 (looking-at c-opt-lambda-key)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2130 (cons 'inlambda (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2131 ((and c-opt-block-stmt-key |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2132 (looking-at c-opt-block-stmt-key)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2133 nil) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2134 (t |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2135 (if (eq (char-after) ?\[) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2136 (setq passed-bracket t)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2137 'maybe)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2138 (if (eq res 'maybe) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2139 (when (and block-follows |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2140 containing-sexp |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2141 (eq (char-after containing-sexp) ?\()) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2142 (goto-char containing-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2143 (if (or (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2144 (c-backward-syntactic-ws lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2145 (and (> (point) (or lim (point-min))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2146 (c-on-identifier))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2147 (and c-special-brace-lists |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2148 (c-looking-at-special-brace-list))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2149 nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2150 (cons 'inexpr-statement (point)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2151 res)))) |
24282 | 2152 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2153 (defun c-looking-at-inexpr-block-backward (paren-state) |
24282 | 2154 ;; Returns non-nil if we're looking at the end of an in-expression |
2155 ;; block, otherwise the same as `c-looking-at-inexpr-block'. | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2156 ;; PAREN-STATE is the paren state relevant at the current position. |
24282 | 2157 (save-excursion |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2158 ;; We currently only recognize a block. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2159 (let ((here (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2160 (elem (car-safe paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2161 containing-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2162 (when (and (consp elem) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2163 (progn (goto-char (cdr elem)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2164 (c-forward-syntactic-ws here) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2165 (= (point) here))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2166 (goto-char (car elem)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2167 (if (setq paren-state (cdr paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2168 (setq containing-sexp (car-safe paren-state))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2169 (c-looking-at-inexpr-block (c-safe-position containing-sexp |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2170 paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2171 containing-sexp))))) |
24282 | 2172 |
36920 | 2173 (defun c-on-identifier () |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2174 "Return non-nil if we're on or directly after an identifier. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2175 Keywords are recognized and not considered identifiers." |
36920 | 2176 (if (or (memq (char-syntax (or (char-after) ? )) '(?w ?_)) |
2177 (memq (char-syntax (or (char-before) ? )) '(?w ?_))) | |
2178 (save-excursion | |
2179 (skip-syntax-backward "w_") | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2180 (not (looking-at c-keywords-regexp))) |
36920 | 2181 (if (c-major-mode-is 'pike-mode) |
2182 ;; Handle the `<operator> syntax in Pike. | |
2183 (save-excursion | |
2184 (if (eq (char-after) ?\`) (forward-char)) | |
2185 (skip-chars-backward "!%&*+\\-/<=>^|~") | |
2186 (let ((pos (point))) | |
2187 (cond ((memq (char-before) '(?\) ?\])) | |
2188 (c-safe (backward-char 2))) | |
2189 ((memq (char-before) '(?\( ?\[)) | |
2190 (c-safe (backward-char 1)))) | |
2191 (if (not (looking-at "()\\|\\[]")) | |
2192 (goto-char pos))) | |
2193 (and (eq (char-before) ?\`) | |
2194 (looking-at "[-!%&*+/<=>^|~]\\|()\\|\\[]")))))) | |
2195 | |
18720 | 2196 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2197 (defun c-most-enclosing-brace (paren-state &optional bufpos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2198 ;; Return the bufpos of the innermost enclosing brace before bufpos |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2199 ;; that hasn't been narrowed out, or nil if none was found. |
18720 | 2200 (let (enclosingp) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2201 (or bufpos (setq bufpos 134217727)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2202 (while paren-state |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2203 (setq enclosingp (car paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2204 paren-state (cdr paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2205 (if (or (consp enclosingp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2206 (>= enclosingp bufpos)) |
18720 | 2207 (setq enclosingp nil) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2208 (if (< enclosingp (point-min)) |
18720 | 2209 (setq enclosingp nil)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2210 (setq paren-state nil))) |
18720 | 2211 enclosingp)) |
2212 | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2213 (defun c-least-enclosing-brace (paren-state &optional bufpos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2214 ;; Return the bufpos of the outermost enclosing brace before bufpos |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2215 ;; that hasn't been narrowed out, or nil if none was found. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2216 (let (pos elem) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2217 (or bufpos (setq bufpos 134217727)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2218 (while paren-state |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2219 (setq elem (car paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2220 paren-state (cdr paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2221 (unless (or (consp elem) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2222 (>= elem bufpos)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2223 (if (>= elem (point-min)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2224 (setq pos elem)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2225 pos)) |
18720 | 2226 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2227 (defun c-safe-position (bufpos paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2228 ;; Return the closest known safe position higher up than BUFPOS, or |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2229 ;; nil if PAREN-STATE doesn't contain one. Return nil if BUFPOS is |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2230 ;; nil, which is useful to find the closest limit before a given |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2231 ;; limit that might be nil. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2232 (when bufpos |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2233 (let ((c-macro-start (c-query-macro-start)) safepos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2234 (if (and c-macro-start |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2235 (< c-macro-start bufpos)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2236 ;; Make sure bufpos is outside the macro we might be in. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2237 (setq bufpos c-macro-start)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2238 (catch 'done |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2239 (while paren-state |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2240 (setq safepos |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2241 (if (consp (car paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2242 (cdr (car paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2243 (car paren-state))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2244 (if (< safepos bufpos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2245 (throw 'done safepos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2246 (setq paren-state (cdr paren-state)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2247 (if (eq c-macro-start bufpos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2248 ;; Backed up bufpos to the macro start and got outside the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2249 ;; state. We know the macro is at the top level in this case, |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2250 ;; so we can use the macro start as the safe position. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2251 c-macro-start))))) |
18720 | 2252 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2253 (defun c-narrow-out-enclosing-class (paren-state lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2254 ;; Narrow the buffer so that the enclosing class is hidden. Uses |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2255 ;; and returns the value from c-search-uplist-for-classkey. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2256 (setq paren-state (c-whack-state-after (point) paren-state)) |
18720 | 2257 (let (inclass-p) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2258 (and paren-state |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2259 (setq inclass-p (c-search-uplist-for-classkey paren-state)) |
18720 | 2260 (narrow-to-region |
2261 (progn | |
2262 (goto-char (1+ (aref inclass-p 1))) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2263 (c-skip-ws-forward lim) |
18720 | 2264 ;; if point is now left of the class opening brace, we're |
2265 ;; hosed, so try a different tact | |
2266 (if (<= (point) (aref inclass-p 1)) | |
2267 (progn | |
2268 (goto-char (1+ (aref inclass-p 1))) | |
2269 (c-forward-syntactic-ws lim))) | |
2270 (point)) | |
2271 ;; end point is the end of the current line | |
2272 (progn | |
2273 (goto-char lim) | |
2274 (c-point 'eol)))) | |
2275 ;; return the class vector | |
2276 inclass-p)) | |
2277 | |
2278 | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2279 ;; c-guess-basic-syntax implements the main decision tree for |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2280 ;; determining the syntactic analysis of the current line of code. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2281 ;; Yes, it's huge and bloated! |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2282 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2283 ;; It's useful to break out some parts of the decision tree to |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2284 ;; separate functions, which are all collected below. Use dynamic |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2285 ;; binding to propagate back the syntax results from them. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2286 (defvar syntax) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2287 (defvar syntactic-relpos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2288 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2289 (defun c-add-stmt-syntax (syntax-symbol |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2290 stop-at-boi-only |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2291 containing-sexp |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2292 paren-state |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2293 &optional at-block-start) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2294 ;; Do the generic processing to anchor the given syntax symbol on |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2295 ;; the preceding statement: Skip over any labels and containing |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2296 ;; statements on the same line, and then search backward until we |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2297 ;; find a statement or block start that begins at boi without a |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2298 ;; label or comment. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2299 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2300 ;; Point is assumed to be at the prospective anchor point for the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2301 ;; given SYNTAX-SYMBOL. More syntax entries are added if we need to |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2302 ;; skip past block opens and containing statement. All the added |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2303 ;; syntax elements will get the same anchor point. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2304 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2305 ;; If STOP-AT-BOI-ONLY is nil, we might stop in the middle of the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2306 ;; line if another statement precedes the current one on this line. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2307 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2308 ;; If AT-BLOCK-START is non-nil, point is taken to be at the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2309 ;; beginning of a block or brace list, which then might be nested |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2310 ;; inside an expression. If AT-BLOCK-START is nil, this is found |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2311 ;; out by checking whether the character at point is "{" or not. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2312 (if (= (point) (c-point 'boi)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2313 ;; This is by far the most common case, so let's give it special |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2314 ;; treatment. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2315 (c-add-syntax syntax-symbol (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2316 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2317 (let* ((savepos (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2318 (syms (list syntax-symbol)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2319 (syms-tail syms) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2320 (boi (c-point 'boi)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2321 (prev-paren (if at-block-start ?{ (char-after))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2322 step-type step-tmp at-comment add-inexpr-stmt) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2323 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2324 ;; Begin by skipping any labels and containing statements that |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2325 ;; are on the same line. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2326 (while (and (/= (point) boi) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2327 (if (memq (setq step-tmp |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2328 (c-beginning-of-statement-1 boi nil t)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2329 '(up label)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2330 t |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2331 (goto-char savepos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2332 nil) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2333 (/= (point) savepos)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2334 (setq savepos (point) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2335 step-type step-tmp)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2336 |
45512
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2337 (catch 'done |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2338 ;; Loop if we have to back out of the containing block. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2339 (while |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2340 (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2341 ;; Loop if we have to back up another statement. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2342 (while |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2343 (progn |
45512
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2344 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2345 ;; Always start by skipping over any comments that |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2346 ;; stands between the statement and boi. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2347 (while (and (/= (setq savepos (point)) boi) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2348 (c-forward-comment -1)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2349 (setq at-comment t |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2350 boi (c-point 'boi))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2351 (goto-char savepos) |
45512
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2352 |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2353 (and |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2354 (or at-comment |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2355 (eq step-type 'label) |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2356 (/= savepos boi)) |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2357 |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2358 (progn |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2359 ;; Current position might not be good enough; |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2360 ;; skip backward another statement. |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2361 (setq step-type (c-beginning-of-statement-1 |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2362 containing-sexp)) |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2363 |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2364 (if (and (not stop-at-boi-only) |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2365 (/= savepos boi) |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2366 (memq step-type '(up previous))) |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2367 ;; If stop-at-boi-only is nil, we shouldn't |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2368 ;; back up over previous or containing |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2369 ;; statements to try to reach boi, so go |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2370 ;; back to the last position and exit. |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2371 (progn |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2372 (goto-char savepos) |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2373 nil) |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2374 (if (and (not stop-at-boi-only) |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2375 (memq step-type '(up previous beginning))) |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2376 ;; If we've moved into another statement |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2377 ;; then we should no longer try to stop |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2378 ;; after boi. |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2379 (setq stop-at-boi-only t)) |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2380 |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2381 ;; Record this a substatement if we skipped up |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2382 ;; one level, but not if we're still on the |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2383 ;; same line. This so e.g. a sequence of "else |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2384 ;; if" clauses won't indent deeper and deeper. |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2385 (when (and (eq step-type 'up) |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2386 (< (point) boi)) |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2387 (setcdr syms-tail (list 'substatement)) |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2388 (setq syms-tail (cdr syms-tail))) |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2389 |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2390 (setq boi (c-point 'boi)) |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2391 (/= (point) savepos))))) |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2392 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2393 (setq savepos (point) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2394 at-comment nil)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2395 (setq at-comment nil) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2396 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2397 (when (and (eq step-type 'same) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2398 containing-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2399 (goto-char containing-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2400 (setq paren-state (c-whack-state-after containing-sexp |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2401 paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2402 containing-sexp (c-most-enclosing-brace paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2403 |
45512
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2404 |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2405 (when (eq (setq prev-paren (char-after)) ?\() |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2406 (c-backward-syntactic-ws containing-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2407 (when (c-on-identifier) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2408 ;; Arrived at a function arglist start. Exit with |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2409 ;; the position of the first argument inside it. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2410 (goto-char savepos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2411 (throw 'done t)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2412 ;; We're in an in-expression statement. Remember |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2413 ;; this. We'll iterate below, but won't add any |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2414 ;; syntax element. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2415 (setq add-inexpr-stmt t)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2416 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2417 (setq savepos (point) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2418 boi (c-point 'boi) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2419 step-type (c-beginning-of-statement-1 containing-sexp)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2420 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2421 (let ((at-bod (and (eq step-type 'same) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2422 (/= savepos (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2423 (eq prev-paren ?{)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2424 (when (= savepos boi) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2425 ;; If the open brace was at boi, we're always |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2426 ;; done. The c-beginning-of-statement-1 call |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2427 ;; above is necessary anyway, to decide the type |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2428 ;; of block-intro to add. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2429 (goto-char savepos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2430 (setq savepos nil)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2431 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2432 (when (eq prev-paren ?{) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2433 (setcdr syms-tail (list (if at-bod |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2434 'defun-block-intro |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2435 'statement-block-intro))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2436 (setq syms-tail (cdr syms-tail))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2437 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2438 (when (and (not at-bod) savepos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2439 ;; Loop if the brace wasn't at boi, and we didn't |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2440 ;; arrive at a defun block. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2441 (if (eq step-type 'same) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2442 ;; Avoid backing up another sexp if the point |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2443 ;; we're at now is found to be good enough in |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2444 ;; the loop above. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2445 (setq step-type nil)) |
45512
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2446 (if (and (not stop-at-boi-only) |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2447 (memq step-type '(up previous beginning))) |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2448 (setq stop-at-boi-only t)) |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2449 (setq boi (c-point 'boi))))) |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
2450 ))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2451 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2452 (while syms |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2453 (c-add-syntax (car syms) (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2454 (setq syms (cdr syms))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2455 (if add-inexpr-stmt |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2456 (c-add-syntax 'inexpr-statement)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2457 ))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2458 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2459 (defun c-add-class-syntax (symbol classkey paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2460 ;; The inclass and class-close syntactic symbols are added in |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2461 ;; several places and some work is needed to fix everything. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2462 ;; Therefore it's collected here. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2463 (save-restriction |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2464 (widen) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2465 (let (inexpr anchor containing-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2466 (goto-char (aref classkey 1)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2467 (if (and (eq symbol 'inclass) (= (point) (c-point 'boi))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2468 (c-add-syntax symbol (setq anchor (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2469 (c-add-syntax symbol (setq anchor (aref classkey 0))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2470 (if (and c-opt-inexpr-class-key |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2471 (setq containing-sexp (c-most-enclosing-brace paren-state |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2472 (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2473 inexpr (cdr (c-looking-at-inexpr-block |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2474 (c-safe-position containing-sexp |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2475 paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2476 containing-sexp))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2477 (/= inexpr (c-point 'boi inexpr))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2478 (c-add-syntax 'inexpr-class))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2479 anchor))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2480 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2481 (defun c-guess-continued-construct (indent-point |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2482 char-after-ip |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2483 beg-of-same-or-containing-stmt |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2484 containing-sexp |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2485 paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2486 ;; This function contains the decision tree reached through both |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2487 ;; cases 18 and 10. It's a continued statement or top level |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2488 ;; construct of some kind. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2489 (let (special-brace-list) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2490 (goto-char indent-point) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2491 (skip-chars-forward " \t") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2492 (cond |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2493 ;; (CASE A removed.) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2494 ;; CASE B: open braces for class or brace-lists |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2495 ((setq special-brace-list |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2496 (or (and c-special-brace-lists |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2497 (c-looking-at-special-brace-list)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2498 (eq char-after-ip ?{))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2499 (cond |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2500 ;; CASE B.1: class-open |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2501 ((save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2502 (goto-char indent-point) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2503 (skip-chars-forward " \t{") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2504 (let ((decl (c-search-uplist-for-classkey (c-parse-state)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2505 (and decl |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2506 (setq beg-of-same-or-containing-stmt (aref decl 0))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2507 )) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2508 (c-add-syntax 'class-open beg-of-same-or-containing-stmt)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2509 ;; CASE B.2: brace-list-open |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2510 ((or (consp special-brace-list) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2511 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2512 (goto-char beg-of-same-or-containing-stmt) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2513 (looking-at "enum\\>[^_]")) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2514 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2515 (goto-char indent-point) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2516 (while (and (> (point) beg-of-same-or-containing-stmt) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2517 (= (c-backward-token-1 1 t) 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2518 (/= (char-after) ?=))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2519 (eq (char-after) ?=))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2520 ;; The most semantically accurate symbol here is |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2521 ;; brace-list-open, but we report it simply as a statement-cont. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2522 ;; The reason is that one normally adjusts brace-list-open for |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2523 ;; brace lists as top-level constructs, and brace lists inside |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2524 ;; statements is a completely different context. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2525 (c-beginning-of-statement-1 containing-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2526 (c-add-stmt-syntax 'statement-cont nil containing-sexp paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2527 ;; CASE B.3: The body of a function declared inside a normal |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2528 ;; block. Can occur e.g. in Pike and when using gcc |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2529 ;; extensions. Might also trigger it with some macros followed |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2530 ;; by blocks, and this gives sane indentation then too. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2531 ;; C.f. cases 16F and 17G. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2532 ((progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2533 (goto-char indent-point) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2534 (and (not (c-looking-at-bos)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2535 (eq (c-beginning-of-statement-1 containing-sexp nil nil t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2536 'same))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2537 (c-add-stmt-syntax 'defun-open t containing-sexp paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2538 ;; CASE B.4: Continued statement with block open. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2539 (t |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2540 (goto-char beg-of-same-or-containing-stmt) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2541 (c-add-stmt-syntax 'statement-cont nil containing-sexp paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2542 (c-add-syntax 'block-open)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2543 )) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2544 ;; CASE C: iostream insertion or extraction operator |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2545 ((and (looking-at "<<\\|>>") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2546 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2547 (goto-char beg-of-same-or-containing-stmt) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2548 (while (and (re-search-forward "<<\\|>>" indent-point 'move) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2549 (c-in-literal beg-of-same-or-containing-stmt))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2550 ;; if we ended up at indent-point, then the first streamop is on a |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2551 ;; separate line. Indent the line like a statement-cont instead |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2552 (when (/= (point) indent-point) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2553 (c-add-syntax 'stream-op (c-point 'boi)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2554 t)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2555 ;; CASE D: continued statement. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2556 (t |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2557 (c-beginning-of-statement-1 containing-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2558 (c-add-stmt-syntax 'statement-cont nil containing-sexp paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2559 ))) |
18720 | 2560 |
2561 (defun c-guess-basic-syntax () | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2562 "Return the syntactic context of the current line." |
18720 | 2563 (save-excursion |
2564 (save-restriction | |
2565 (beginning-of-line) | |
2566 (let* ((indent-point (point)) | |
2567 (case-fold-search nil) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2568 (paren-state (c-parse-state)) |
18720 | 2569 literal containing-sexp char-before-ip char-after-ip lim |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2570 syntax placeholder c-in-literal-cache step-type |
24282 | 2571 tmpsymbol keyword injava-inher special-brace-list |
18720 | 2572 ;; narrow out any enclosing class or extern "C" block |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2573 (inclass-p (c-narrow-out-enclosing-class paren-state |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2574 indent-point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2575 ;; c-state-cache is shadowed here. That means we must |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2576 ;; not do any changes during the execution of this |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2577 ;; function, since c-check-state-cache then would change |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2578 ;; this local variable and leave a bogus value in the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2579 ;; global one. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2580 (c-state-cache (if inclass-p |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2581 (c-whack-state-before (point-min) paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2582 paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2583 (c-state-cache-start (point-min)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2584 inenclosing-p macro-start in-macro-expr |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2585 ;; There's always at most one syntactic element which got |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2586 ;; a relpos. It's stored in syntactic-relpos. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2587 syntactic-relpos |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2588 (c-stmt-delim-chars c-stmt-delim-chars)) |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2589 ;; 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
|
2590 ;; 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
|
2591 ;; definitions. |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2592 (save-excursion |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2593 (save-restriction |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2594 (widen) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2595 (if (and inclass-p |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2596 (progn |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2597 (goto-char (aref inclass-p 0)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2598 (looking-at c-other-decl-block-key))) |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2599 (let ((enclosing (match-string 1))) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2600 (cond |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2601 ((string-equal enclosing "extern") |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2602 (setq inenclosing-p 'extern)) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2603 ((string-equal enclosing "namespace") |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2604 (setq inenclosing-p 'namespace)) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2605 ))))) |
18720 | 2606 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2607 ;; Init some position variables: |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2608 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2609 ;; containing-sexp is the open paren of the closest |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2610 ;; surrounding sexp or nil if there is none that hasn't been |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2611 ;; narrowed out. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2612 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2613 ;; lim is the position after the closest preceding brace sexp |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2614 ;; (nested sexps are ignored), or the position after |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2615 ;; containing-sexp if there is none, or (point-min) if |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2616 ;; containing-sexp is nil. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2617 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2618 ;; c-state-cache is the state from c-parse-state at |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2619 ;; indent-point, without any parens outside the region |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2620 ;; narrowed by c-narrow-out-enclosing-class. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2621 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2622 ;; paren-state is the state from c-parse-state outside |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2623 ;; containing-sexp, or at indent-point if containing-sexp is |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2624 ;; nil. paren-state is not limited to the narrowed region, as |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2625 ;; opposed to c-state-cache. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2626 (if c-state-cache |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2627 (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2628 (setq containing-sexp (car paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2629 paren-state (cdr paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2630 (if (consp containing-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2631 (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2632 (setq lim (cdr containing-sexp)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2633 (if (cdr c-state-cache) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2634 ;; Ignore balanced paren. The next entry |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2635 ;; can't be another one. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2636 (setq containing-sexp (car (cdr c-state-cache)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2637 paren-state (cdr paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2638 ;; If there is no surrounding open paren then |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2639 ;; put the last balanced pair back on paren-state. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2640 (setq paren-state (cons containing-sexp paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2641 containing-sexp nil))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2642 (setq lim (1+ containing-sexp)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2643 (setq lim (point-min))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2644 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2645 ;; If we're in a parenthesis list then ',' delimits the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2646 ;; "statements" rather than being an operator (with the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2647 ;; exception of the "for" clause). This difference is |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2648 ;; typically only noticeable when statements are used in macro |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2649 ;; arglists. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2650 (when (and containing-sexp |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2651 (eq (char-after containing-sexp) ?\()) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2652 (setq c-stmt-delim-chars c-stmt-delim-chars-with-comma)) |
18720 | 2653 |
2654 ;; cache char before and after indent point, and move point to | |
2655 ;; the most likely position to perform the majority of tests | |
2656 (goto-char indent-point) | |
2657 (c-backward-syntactic-ws lim) | |
2658 (setq char-before-ip (char-before)) | |
2659 (goto-char indent-point) | |
2660 (skip-chars-forward " \t") | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2661 (setq char-after-ip (char-after)) |
18720 | 2662 |
2663 ;; are we in a literal? | |
2664 (setq literal (c-in-literal lim)) | |
2665 | |
2666 ;; now figure out syntactic qualities of the current line | |
2667 (cond | |
2668 ;; CASE 1: in a string. | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2669 ((eq literal 'string) |
18720 | 2670 (c-add-syntax 'string (c-point 'bopl))) |
2671 ;; CASE 2: in a C or C++ style comment. | |
2672 ((memq literal '(c c++)) | |
26817 | 2673 (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
|
2674 ;; CASE 3: in a cpp preprocessor macro continuation. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2675 ((and (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2676 (when (c-beginning-of-macro) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2677 (setq macro-start (point)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2678 (/= macro-start (c-point 'boi)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2679 (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2680 (setq tmpsymbol 'cpp-macro-cont) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2681 (or (not c-syntactic-indentation-in-macros) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2682 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2683 (goto-char macro-start) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2684 ;; If at the beginning of the body of a #define |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2685 ;; directive then analyze as cpp-define-intro |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2686 ;; only. Go on with the syntactic analysis |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2687 ;; otherwise. in-macro-expr is set if we're in a |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2688 ;; cpp expression, i.e. before the #define body |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2689 ;; or anywhere in a non-#define directive. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2690 (if (c-forward-to-cpp-define-body) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2691 (let ((indent-boi (c-point 'boi indent-point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2692 (setq in-macro-expr (> (point) indent-boi) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2693 tmpsymbol 'cpp-define-intro) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2694 (= (point) indent-boi)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2695 (setq in-macro-expr t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2696 nil))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2697 (c-add-syntax tmpsymbol macro-start) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2698 (setq macro-start nil)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2699 ;; CASE 11: an else clause? |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2700 ((looking-at "else\\>[^_]") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2701 (c-beginning-of-statement-1 containing-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2702 (c-add-stmt-syntax 'else-clause t containing-sexp paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2703 ;; CASE 12: while closure of a do/while construct? |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2704 ((and (looking-at "while\\>[^_]") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2705 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2706 (prog1 (eq (c-beginning-of-statement-1 containing-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2707 'beginning) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2708 (setq placeholder (point))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2709 (goto-char placeholder) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2710 (c-add-stmt-syntax 'do-while-closure t containing-sexp paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2711 ;; CASE 13: A catch or finally clause? This case is simpler |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2712 ;; than if-else and do-while, because a block is required |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2713 ;; after every try, catch and finally. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2714 ((save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2715 (and (cond ((c-major-mode-is 'c++-mode) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2716 (looking-at "catch\\>[^_]")) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2717 ((c-major-mode-is 'java-mode) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2718 (looking-at "\\(catch\\|finally\\)\\>[^_]"))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2719 (and (c-safe (c-backward-syntactic-ws) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2720 (c-backward-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2721 t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2722 (eq (char-after) ?{) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2723 (c-safe (c-backward-syntactic-ws) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2724 (c-backward-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2725 t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2726 (if (eq (char-after) ?\() |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2727 (c-safe (c-backward-sexp) t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2728 t)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2729 (looking-at "\\(try\\|catch\\)\\>[^_]") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2730 (setq placeholder (point)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2731 (goto-char placeholder) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2732 (c-add-stmt-syntax 'catch-clause t containing-sexp paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2733 ;; CASE 18: A substatement we can recognize by keyword. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2734 ((save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2735 (and c-opt-block-stmt-key |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2736 (not (eq char-before-ip ?\;)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2737 (not (memq char-after-ip '(?\) ?\] ?,))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2738 (or (not (eq char-before-ip ?})) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2739 (c-looking-at-inexpr-block-backward c-state-cache)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2740 (> (point) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2741 (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2742 ;; Ought to cache the result from the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2743 ;; c-beginning-of-statement-1 calls here. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2744 (setq placeholder (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2745 (while (eq (setq step-type |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2746 (c-beginning-of-statement-1 lim)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2747 'label)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2748 (if (eq step-type 'previous) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2749 (goto-char placeholder) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2750 (setq placeholder (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2751 (if (and (eq step-type 'same) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2752 (not (looking-at c-opt-block-stmt-key))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2753 ;; Step up to the containing statement if we |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2754 ;; stayed in the same one. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2755 (let (step) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2756 (while (eq |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2757 (setq step |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2758 (c-beginning-of-statement-1 lim)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2759 'label)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2760 (if (eq step 'up) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2761 (setq placeholder (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2762 ;; There was no containing statement afterall. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2763 (goto-char placeholder))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2764 placeholder)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2765 (if (looking-at c-block-stmt-2-key) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2766 ;; Require a parenthesis after these keywords. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2767 ;; Necessary to catch e.g. synchronized in Java, |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2768 ;; which can be used both as statement and |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2769 ;; modifier. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2770 (and (= (c-forward-token-1 1 nil) 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2771 (eq (char-after) ?\()) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2772 (looking-at c-opt-block-stmt-key)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2773 (if (eq step-type 'up) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2774 ;; CASE 18A: Simple substatement. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2775 (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2776 (goto-char placeholder) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2777 (cond |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2778 ((eq char-after-ip ?{) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2779 (c-add-stmt-syntax 'substatement-open nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2780 containing-sexp paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2781 ((save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2782 (goto-char indent-point) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2783 (back-to-indentation) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2784 (looking-at c-label-key)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2785 (c-add-stmt-syntax 'substatement-label nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2786 containing-sexp paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2787 (t |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2788 (c-add-stmt-syntax 'substatement nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2789 containing-sexp paren-state)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2790 ;; CASE 18B: Some other substatement. This is shared |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2791 ;; with case 10. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2792 (c-guess-continued-construct indent-point |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2793 char-after-ip |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2794 placeholder |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2795 lim |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2796 paren-state))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2797 ;; CASE 4: In-expression statement. C.f. cases 7B, 16A and |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2798 ;; 17E. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2799 ((and (or c-opt-inexpr-class-key |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2800 c-opt-inexpr-block-key |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2801 c-opt-lambda-key) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2802 (setq placeholder (c-looking-at-inexpr-block |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2803 (c-safe-position containing-sexp paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2804 containing-sexp))) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
2805 (setq tmpsymbol (assq (car placeholder) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
2806 '((inexpr-class . class-open) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
2807 (inexpr-statement . block-open)))) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
2808 (if tmpsymbol |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
2809 ;; 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
|
2810 (setq tmpsymbol (cdr tmpsymbol)) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
2811 ;; 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
|
2812 ;; 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
|
2813 ;; opener. |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
2814 (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
|
2815 'inline-open |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
2816 'lambda-intro-cont))) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
2817 (goto-char (cdr placeholder)) |
36920 | 2818 (back-to-indentation) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2819 (c-add-stmt-syntax tmpsymbol t |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2820 (c-most-enclosing-brace c-state-cache (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2821 (c-whack-state-after (point) paren-state)) |
36920 | 2822 (unless (eq (point) (cdr placeholder)) |
2823 (c-add-syntax (car placeholder)))) | |
18720 | 2824 ;; CASE 5: Line is at top level. |
2825 ((null containing-sexp) | |
2826 (cond | |
24282 | 2827 ;; CASE 5A: we are looking at a defun, brace list, class, |
2828 ;; or inline-inclass method opening brace | |
2829 ((setq special-brace-list | |
2830 (or (and c-special-brace-lists | |
2831 (c-looking-at-special-brace-list)) | |
2832 (eq char-after-ip ?{))) | |
18720 | 2833 (cond |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2834 ;; CASE 5A.1: extern language or namespace construct |
18720 | 2835 ((save-excursion |
2836 (goto-char indent-point) | |
2837 (skip-chars-forward " \t") | |
24282 | 2838 (and (c-safe (progn (c-backward-sexp 2) t)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2839 (looking-at c-other-decl-block-key) |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2840 (setq keyword (match-string 1) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2841 placeholder (point)) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2842 (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
|
2843 (setq tmpsymbol 'namespace-open)) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2844 (and (string-equal keyword "extern") |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2845 (progn |
24282 | 2846 (c-forward-sexp 1) |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2847 (c-forward-syntactic-ws) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2848 (eq (char-after) ?\")) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2849 (setq tmpsymbol 'extern-lang-open))) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2850 )) |
18720 | 2851 (goto-char placeholder) |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
2852 (c-add-syntax tmpsymbol (c-point 'boi))) |
18720 | 2853 ;; CASE 5A.2: we are looking at a class opening brace |
2854 ((save-excursion | |
2855 (goto-char indent-point) | |
2856 (skip-chars-forward " \t{") | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2857 (let ((decl (c-search-uplist-for-classkey (c-parse-state)))) |
18720 | 2858 (and decl |
2859 (setq placeholder (aref decl 0))) | |
2860 )) | |
2861 (c-add-syntax 'class-open placeholder)) | |
2862 ;; CASE 5A.3: brace list open | |
2863 ((save-excursion | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2864 (c-beginning-of-statement-1 lim t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2865 (if (looking-at "typedef\\>[^_]") |
24282 | 2866 (progn (c-forward-sexp 1) |
18720 | 2867 (c-forward-syntactic-ws indent-point))) |
2868 (setq placeholder (c-point 'boi)) | |
24282 | 2869 (or (consp special-brace-list) |
36920 | 2870 (and (or (save-excursion |
24282 | 2871 (goto-char indent-point) |
36920 | 2872 (setq tmpsymbol nil) |
24282 | 2873 (while (and (> (point) placeholder) |
2874 (= (c-backward-token-1 1 t) 0) | |
36920 | 2875 (/= (char-after) ?=)) |
2876 (if (and (not tmpsymbol) | |
2877 (looking-at "new\\>[^_]")) | |
2878 (setq tmpsymbol 'topmost-intro-cont))) | |
2879 (eq (char-after) ?=)) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2880 (looking-at "enum\\>[^_]")) |
21106
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
2881 (save-excursion |
24282 | 2882 (while (and (< (point) indent-point) |
2883 (= (c-forward-token-1 1 t) 0) | |
2884 (not (memq (char-after) '(?\; ?\())))) | |
2885 (not (memq (char-after) '(?\; ?\())) | |
2886 )))) | |
36920 | 2887 (if (and (c-major-mode-is 'java-mode) |
2888 (eq tmpsymbol 'topmost-intro-cont)) | |
2889 ;; We're in Java and have found that the open brace | |
2890 ;; belongs to a "new Foo[]" initialization list, | |
2891 ;; which means the brace list is part of an | |
2892 ;; expression and not a top level definition. We | |
2893 ;; therefore treat it as any topmost continuation | |
2894 ;; even though the semantically correct symbol still | |
2895 ;; is brace-list-open, on the same grounds as in | |
2896 ;; case 10B.2. | |
2897 (progn | |
2898 (c-beginning-of-statement-1 lim) | |
2899 (c-add-syntax 'topmost-intro-cont (c-point 'boi))) | |
2900 (c-add-syntax 'brace-list-open placeholder))) | |
18720 | 2901 ;; 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
|
2902 ((and inclass-p (not inenclosing-p)) |
18720 | 2903 (c-add-syntax 'inline-open) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2904 (c-add-class-syntax 'inclass inclass-p paren-state)) |
18720 | 2905 ;; CASE 5A.5: ordinary defun open |
2906 (t | |
2907 (goto-char placeholder) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2908 (if (or inclass-p macro-start) |
21106
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
2909 (c-add-syntax 'defun-open (c-point 'boi)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2910 ;; Bogus to use bol here, but it's the legacy. |
21106
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
2911 (c-add-syntax 'defun-open (c-point 'bol))) |
18720 | 2912 ))) |
2913 ;; CASE 5B: first K&R arg decl or member init | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2914 ((c-just-after-func-arglist-p nil lim) |
18720 | 2915 (cond |
2916 ;; CASE 5B.1: a member init | |
2917 ((or (eq char-before-ip ?:) | |
2918 (eq char-after-ip ?:)) | |
2919 ;; this line should be indented relative to the beginning | |
2920 ;; of indentation for the topmost-intro line that contains | |
2921 ;; the prototype's open paren | |
2922 ;; TBD: is the following redundant? | |
2923 (if (eq char-before-ip ?:) | |
2924 (forward-char -1)) | |
2925 (c-backward-syntactic-ws lim) | |
2926 ;; TBD: is the preceding redundant? | |
2927 (if (eq (char-before) ?:) | |
2928 (progn (forward-char -1) | |
2929 (c-backward-syntactic-ws lim))) | |
2930 (if (eq (char-before) ?\)) | |
24282 | 2931 (c-backward-sexp 1)) |
18720 | 2932 (setq placeholder (point)) |
2933 (save-excursion | |
24282 | 2934 (and (c-safe (c-backward-sexp 1) t) |
18720 | 2935 (looking-at "throw[^_]") |
24282 | 2936 (c-safe (c-backward-sexp 1) t) |
18720 | 2937 (setq placeholder (point)))) |
2938 (goto-char placeholder) | |
2939 (c-add-syntax 'member-init-intro (c-point 'boi)) | |
2940 ;; we don't need to add any class offset since this | |
2941 ;; should be relative to the ctor's indentation | |
2942 ) | |
2943 ;; CASE 5B.2: K&R arg decl intro | |
2944 (c-recognize-knr-p | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2945 (c-beginning-of-statement-1 lim) |
18720 | 2946 (c-add-syntax 'knr-argdecl-intro (c-point 'boi)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2947 (if inclass-p |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2948 (c-add-class-syntax 'inclass inclass-p paren-state))) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
2949 ;; 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
|
2950 ((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
|
2951 (c-forward-syntactic-ws) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
2952 (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
|
2953 ;; CASE 5B.4: Nether region after a C++ or Java func |
18720 | 2954 ;; decl, which could include a `throws' declaration. |
2955 (t | |
2956 (c-beginning-of-statement-1 lim) | |
2957 (c-add-syntax 'func-decl-cont (c-point 'boi)) | |
2958 ))) | |
2959 ;; CASE 5C: inheritance line. could be first inheritance | |
2960 ;; line, or continuation of a multiple inheritance | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2961 ((or (and (c-major-mode-is 'c++-mode) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
2962 (progn |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
2963 (when (eq char-after-ip ?,) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
2964 (skip-chars-forward " \t") |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
2965 (forward-char)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2966 (looking-at c-opt-decl-spec-key))) |
18720 | 2967 (and (or (eq char-before-ip ?:) |
2968 ;; watch out for scope operator | |
2969 (save-excursion | |
2970 (and (eq char-after-ip ?:) | |
2971 (c-safe (progn (forward-char 1) t)) | |
2972 (not (eq (char-after) ?:)) | |
2973 ))) | |
2974 (save-excursion | |
2975 (c-backward-syntactic-ws lim) | |
2976 (if (eq char-before-ip ?:) | |
2977 (progn | |
2978 (forward-char -1) | |
2979 (c-backward-syntactic-ws lim))) | |
2980 (back-to-indentation) | |
2981 (looking-at c-class-key))) | |
2982 ;; for Java | |
24282 | 2983 (and (c-major-mode-is 'java-mode) |
18720 | 2984 (let ((fence (save-excursion |
2985 (c-beginning-of-statement-1 lim) | |
2986 (point))) | |
2987 cont done) | |
2988 (save-excursion | |
2989 (while (not done) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
2990 (cond ((looking-at c-opt-decl-spec-key) |
18720 | 2991 (setq injava-inher (cons cont (point)) |
2992 done t)) | |
24282 | 2993 ((or (not (c-safe (c-forward-sexp -1) t)) |
18720 | 2994 (<= (point) fence)) |
2995 (setq done t)) | |
2996 ) | |
2997 (setq cont t))) | |
2998 injava-inher) | |
2999 (not (c-crosses-statement-barrier-p (cdr injava-inher) | |
3000 (point))) | |
3001 )) | |
3002 (cond | |
3003 ;; CASE 5C.1: non-hanging colon on an inher intro | |
3004 ((eq char-after-ip ?:) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3005 (c-beginning-of-statement-1 lim) |
18720 | 3006 (c-add-syntax 'inher-intro (c-point 'boi)) |
3007 ;; don't add inclass symbol since relative point already | |
3008 ;; contains any class offset | |
3009 ) | |
3010 ;; CASE 5C.2: hanging colon on an inher intro | |
3011 ((eq char-before-ip ?:) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3012 (c-beginning-of-statement-1 lim) |
18720 | 3013 (c-add-syntax 'inher-intro (c-point 'boi)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3014 (if inclass-p |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3015 (c-add-class-syntax 'inclass inclass-p paren-state))) |
18720 | 3016 ;; CASE 5C.3: in a Java implements/extends |
3017 (injava-inher | |
3018 (let ((where (cdr injava-inher)) | |
3019 (cont (car injava-inher))) | |
3020 (goto-char where) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3021 (cond ((looking-at "throws\\>[^_]") |
18720 | 3022 (c-add-syntax 'func-decl-cont |
3023 (progn (c-beginning-of-statement-1 lim) | |
3024 (c-point 'boi)))) | |
3025 (cont (c-add-syntax 'inher-cont where)) | |
3026 (t (c-add-syntax 'inher-intro | |
3027 (progn (goto-char (cdr injava-inher)) | |
3028 (c-beginning-of-statement-1 lim) | |
3029 (point)))) | |
3030 ))) | |
3031 ;; CASE 5C.4: a continued inheritance line | |
3032 (t | |
3033 (c-beginning-of-inheritance-list lim) | |
3034 (c-add-syntax 'inher-cont (point)) | |
3035 ;; don't add inclass symbol since relative point already | |
3036 ;; contains any class offset | |
3037 ))) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3038 ;; CASE 5D: this could be a top-level initialization, a |
26817 | 3039 ;; member init list continuation, or a template argument |
3040 ;; list continuation. | |
3041 ((c-with-syntax-table (if (c-major-mode-is 'c++-mode) | |
3042 c++-template-syntax-table | |
3043 (syntax-table)) | |
3044 (save-excursion | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3045 ;; Note: We use the fact that lim is always after any |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3046 ;; preceding brace sexp. |
26817 | 3047 (while (and (= (c-backward-token-1 1 t lim) 0) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3048 (not (looking-at "[;<,=]")))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3049 (or (memq (char-after) '(?, ?=)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3050 (and (c-major-mode-is 'c++-mode) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3051 (= (c-backward-token-1 1 nil lim) 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3052 (eq (char-after) ?<))))) |
18720 | 3053 (goto-char indent-point) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3054 (c-beginning-of-member-init-list lim) |
18720 | 3055 (cond |
3056 ;; CASE 5D.1: hanging member init colon, but watch out | |
3057 ;; for bogus matches on access specifiers inside classes. | |
24282 | 3058 ((and (save-excursion |
3059 (setq placeholder (point)) | |
26817 | 3060 (c-backward-token-1 1 t lim) |
3061 (and (eq (char-after) ?:) | |
3062 (not (eq (char-before) ?:)))) | |
18720 | 3063 (save-excursion |
24282 | 3064 (goto-char placeholder) |
3065 (back-to-indentation) | |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3066 (or |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3067 (/= (car (save-excursion |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3068 (parse-partial-sexp (point) placeholder))) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3069 0) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3070 (and |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3071 (if c-opt-access-key |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3072 (not (looking-at c-opt-access-key)) t) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3073 (not (looking-at c-class-key)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3074 (if c-opt-bitfield-key |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3075 (not (looking-at c-opt-bitfield-key)) t)) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3076 ))) |
24282 | 3077 (goto-char placeholder) |
3078 (c-forward-syntactic-ws) | |
3079 (c-add-syntax 'member-init-cont (point)) | |
18720 | 3080 ;; we do not need to add class offset since relative |
3081 ;; point is the member init above us | |
3082 ) | |
3083 ;; CASE 5D.2: non-hanging member init colon | |
3084 ((progn | |
3085 (c-forward-syntactic-ws indent-point) | |
3086 (eq (char-after) ?:)) | |
3087 (skip-chars-forward " \t:") | |
3088 (c-add-syntax 'member-init-cont (point))) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3089 ;; CASE 5D.3: perhaps a template list continuation? |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3090 ((and (c-major-mode-is 'c++-mode) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3091 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3092 (save-restriction |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3093 (c-with-syntax-table c++-template-syntax-table |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3094 (goto-char indent-point) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3095 (setq placeholder (c-up-list-backward (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3096 (and placeholder |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3097 (eq (char-after placeholder) ?<)))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3098 ;; we can probably indent it just like an arglist-cont |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3099 (goto-char placeholder) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3100 (c-beginning-of-statement-1 lim t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3101 (c-add-syntax 'template-args-cont (c-point 'boi))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3102 ;; CASE 5D.4: perhaps a multiple inheritance line? |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3103 ((and (c-major-mode-is 'c++-mode) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3104 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3105 (c-beginning-of-statement-1 lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3106 (setq placeholder (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3107 (if (looking-at "static\\>[^_]") |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3108 (c-forward-token-1 1 nil indent-point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3109 (and (looking-at c-class-key) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3110 (= (c-forward-token-1 2 nil indent-point) 0) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3111 (if (eq (char-after) ?<) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3112 (c-with-syntax-table c++-template-syntax-table |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3113 (= (c-forward-token-1 1 t indent-point) 0)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3114 t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3115 (eq (char-after) ?:)))) |
24282 | 3116 (goto-char placeholder) |
18720 | 3117 (c-add-syntax 'inher-cont (c-point 'boi))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3118 ;; CASE 5D.5: Continuation of the "expression part" of a |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3119 ;; top level construct. |
18720 | 3120 (t |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3121 (while (and (eq (car (c-beginning-of-decl-1 containing-sexp)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3122 'same) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3123 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3124 (c-backward-syntactic-ws) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3125 (eq (char-before) ?})))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3126 (c-add-stmt-syntax |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3127 (if (eq char-before-ip ?,) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3128 ;; A preceding comma at the top level means that a |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3129 ;; new variable declaration starts here. Use |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3130 ;; topmost-intro-cont for it, for consistency with |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3131 ;; the first variable declaration. C.f. case 5N. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3132 'topmost-intro-cont |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3133 'statement-cont) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3134 nil containing-sexp paren-state)) |
18720 | 3135 )) |
3136 ;; CASE 5E: we are looking at a access specifier | |
3137 ((and inclass-p | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3138 c-opt-access-key |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3139 (looking-at c-opt-access-key)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3140 (setq placeholder (c-add-class-syntax 'inclass inclass-p |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3141 paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3142 ;; Append access-label with the same anchor point as inclass gets. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3143 (nconc syntax (list (cons 'access-label placeholder)))) |
21106
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
3144 ;; 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
|
3145 ((and inenclosing-p |
18720 | 3146 (eq char-after-ip ?})) |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
3147 (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
|
3148 'extern-lang-close |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
3149 'namespace-close)) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
3150 (c-add-syntax tmpsymbol (aref inclass-p 0))) |
18720 | 3151 ;; CASE 5G: we are looking at the brace which closes the |
3152 ;; enclosing nested class decl | |
3153 ((and inclass-p | |
3154 (eq char-after-ip ?}) | |
3155 (save-excursion | |
3156 (save-restriction | |
3157 (widen) | |
3158 (forward-char 1) | |
24282 | 3159 (and (c-safe (progn (c-backward-sexp 1) t)) |
3160 (= (point) (aref inclass-p 1)) | |
3161 )))) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3162 (c-add-class-syntax 'class-close inclass-p paren-state)) |
18720 | 3163 ;; CASE 5H: we could be looking at subsequent knr-argdecls |
3164 ((and c-recognize-knr-p | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3165 (not (eq char-before-ip ?})) |
18720 | 3166 (save-excursion |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3167 (setq placeholder (cdr (c-beginning-of-decl-1 lim))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3168 (and placeholder |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3169 ;; Do an extra check to avoid tripping up on |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3170 ;; statements that occur in invalid contexts |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3171 ;; (e.g. in macro bodies where we don't really |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3172 ;; know the context of what we're looking at). |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3173 (not (and c-opt-block-stmt-key |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3174 (looking-at c-opt-block-stmt-key))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3175 (< placeholder indent-point)) |
18720 | 3176 (goto-char placeholder) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3177 (c-add-syntax 'knr-argdecl (point))) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3178 ;; CASE 5I: ObjC method definition. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3179 ((and c-opt-method-key |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3180 (looking-at c-opt-method-key)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3181 (c-beginning-of-statement-1 lim) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3182 (c-add-syntax 'objc-method-intro (c-point 'boi))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3183 ;; CASE 5N: At a variable declaration that follows a class |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3184 ;; definition or some other block declaration that doesn't |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3185 ;; end at the closing '}'. C.f. case 5D.5. |
18720 | 3186 ((progn |
3187 (c-backward-syntactic-ws lim) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3188 (and (eq (char-before) ?}) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3189 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3190 (let ((start (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3191 (if paren-state |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3192 ;; Speed up the backward search a bit. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3193 (goto-char (car (car paren-state)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3194 (c-beginning-of-decl-1 containing-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3195 (setq placeholder (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3196 (if (= start (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3197 ;; The '}' is unbalanced. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3198 nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3199 (c-end-of-decl-1) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3200 (> (point) indent-point)))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3201 (goto-char placeholder) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3202 (c-add-stmt-syntax 'topmost-intro-cont nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3203 containing-sexp paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3204 ;; CASE 5J: we are at the topmost level, make |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3205 ;; sure we skip back past any access specifiers |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3206 ((progn |
18720 | 3207 (while (and inclass-p |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3208 c-opt-access-key |
18720 | 3209 (not (bobp)) |
3210 (save-excursion | |
24282 | 3211 (c-safe (progn (c-backward-sexp 1) t)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3212 (looking-at c-opt-access-key))) |
24282 | 3213 (c-backward-sexp 1) |
18720 | 3214 (c-backward-syntactic-ws lim)) |
3215 (or (bobp) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3216 (memq (char-before) '(?\; ?})) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3217 (and (c-major-mode-is 'objc-mode) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3218 (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3219 (c-beginning-of-statement-1 lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3220 (eq (char-after) ?@))))) |
18720 | 3221 ;; real beginning-of-line could be narrowed out due to |
3222 ;; enclosure in a class block | |
3223 (save-restriction | |
3224 (widen) | |
3225 (c-add-syntax 'topmost-intro (c-point 'bol)) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3226 ;; Using bol instead of boi above is highly bogus, and |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3227 ;; it makes our lives hard to remain compatible. :P |
18720 | 3228 (if inclass-p |
3229 (progn | |
3230 (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
|
3231 (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
|
3232 (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
|
3233 (cond |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
3234 ((eq inenclosing-p 'extern) |
21106
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
3235 (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
|
3236 ((eq inenclosing-p 'namespace) |
21106
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
3237 (c-add-syntax 'innamespace (c-point 'boi))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3238 (t (c-add-class-syntax 'inclass inclass-p paren-state))) |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
3239 )) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3240 (when (and c-syntactic-indentation-in-macros |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3241 macro-start |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3242 (/= macro-start (c-point 'boi indent-point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3243 (c-add-syntax 'cpp-define-intro) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3244 (setq macro-start nil)) |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
3245 )) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3246 ;; CASE 5K: we are at an ObjC method definition |
18720 | 3247 ;; continuation line. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3248 ((and c-opt-method-key |
18720 | 3249 (progn |
3250 (c-beginning-of-statement-1 lim) | |
3251 (beginning-of-line) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3252 (looking-at c-opt-method-key))) |
18720 | 3253 (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
|
3254 ;; CASE 5L: we are at the first argument of a template |
26817 | 3255 ;; arglist that begins on the previous line. |
3256 ((eq (char-before) ?<) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3257 (c-beginning-of-statement-1 (c-safe-position (point) paren-state)) |
26817 | 3258 (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
|
3259 ;; CASE 5M: we are at a topmost continuation line |
18720 | 3260 (t |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3261 (c-beginning-of-statement-1 (c-safe-position (point) paren-state)) |
18720 | 3262 (c-add-syntax 'topmost-intro-cont (c-point 'boi))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3263 )) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3264 ;; (CASE 6 has been removed.) |
24282 | 3265 ;; CASE 7: line is an expression, not a statement. Most |
18720 | 3266 ;; likely we are either in a function prototype or a function |
3267 ;; call argument list | |
24282 | 3268 ((not (or (and c-special-brace-lists |
3269 (save-excursion | |
3270 (goto-char containing-sexp) | |
3271 (c-looking-at-special-brace-list))) | |
3272 (eq (char-after containing-sexp) ?{))) | |
18720 | 3273 (cond |
24282 | 3274 ;; CASE 7A: we are looking at the arglist closing paren |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3275 ((memq char-after-ip '(?\) ?\])) |
18720 | 3276 (goto-char containing-sexp) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3277 (setq placeholder (c-point 'boi)) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3278 (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
|
3279 (> (point) placeholder)) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3280 (forward-char) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3281 (skip-chars-forward " \t") |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3282 (setq placeholder (point))) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3283 (c-add-syntax 'arglist-close placeholder)) |
24282 | 3284 ;; CASE 7B: Looking at the opening brace of an |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3285 ;; in-expression block or brace list. C.f. cases 4, 16A |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3286 ;; and 17E. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3287 ((and (eq char-after-ip ?{) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3288 (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3289 (setq placeholder (c-inside-bracelist-p (point) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3290 c-state-cache)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3291 (if placeholder |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3292 (setq tmpsymbol '(brace-list-open . inexpr-class)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3293 (setq tmpsymbol '(block-open . inexpr-statement) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3294 placeholder |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3295 (cdr-safe (c-looking-at-inexpr-block |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3296 (c-safe-position containing-sexp |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3297 paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3298 containing-sexp))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3299 ;; placeholder is nil if it's a block directly in |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3300 ;; a function arglist. That makes us skip out of |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3301 ;; this case. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3302 ))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3303 (goto-char placeholder) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3304 (back-to-indentation) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3305 (c-add-stmt-syntax (car tmpsymbol) t |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3306 (c-most-enclosing-brace paren-state (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3307 (c-whack-state-after (point) paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3308 (if (/= (point) placeholder) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3309 (c-add-syntax (cdr tmpsymbol)))) |
24282 | 3310 ;; CASE 7C: we are looking at the first argument in an empty |
18720 | 3311 ;; argument list. Use arglist-close if we're actually |
3312 ;; looking at a close paren or bracket. | |
3313 ((memq char-before-ip '(?\( ?\[)) | |
3314 (goto-char containing-sexp) | |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3315 (setq placeholder (c-point 'boi)) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3316 (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
|
3317 (> (point) placeholder)) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3318 (forward-char) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3319 (skip-chars-forward " \t") |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3320 (setq placeholder (point))) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3321 (c-add-syntax 'arglist-intro placeholder)) |
24282 | 3322 ;; CASE 7D: we are inside a conditional test clause. treat |
18720 | 3323 ;; these things as statements |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3324 ((progn |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
3325 (goto-char containing-sexp) |
24282 | 3326 (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
|
3327 (looking-at "\\<for\\>[^_]"))) |
18720 | 3328 (goto-char (1+ containing-sexp)) |
3329 (c-forward-syntactic-ws indent-point) | |
3330 (if (eq char-before-ip ?\;) | |
3331 (c-add-syntax 'statement (point)) | |
3332 (c-add-syntax 'statement-cont (point)) | |
3333 )) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3334 ;; CASE 7E: maybe a continued ObjC method call. This is the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3335 ;; case when we are inside a [] bracketed exp, and what |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3336 ;; precede the opening bracket is not an identifier. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3337 ((and c-opt-method-key |
18720 | 3338 (eq (char-after containing-sexp) ?\[) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3339 (progn |
18720 | 3340 (goto-char (1- containing-sexp)) |
3341 (c-backward-syntactic-ws (c-point 'bod)) | |
3342 (if (not (looking-at c-symbol-key)) | |
3343 (c-add-syntax 'objc-method-call-cont containing-sexp)) | |
3344 ))) | |
24282 | 3345 ;; CASE 7F: we are looking at an arglist continuation line, |
18720 | 3346 ;; but the preceding argument is on the same line as the |
3347 ;; opening paren. This case includes multi-line | |
3348 ;; mathematical paren groupings, but we could be on a | |
3349 ;; for-list continuation line | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3350 ((progn |
36920 | 3351 (goto-char (1+ containing-sexp)) |
3352 (skip-chars-forward " \t") | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3353 (and (not (eolp)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3354 (not (looking-at "\\\\$")))) |
18720 | 3355 (goto-char containing-sexp) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3356 (setq placeholder (c-point 'boi)) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3357 (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
|
3358 (> (point) placeholder)) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3359 (forward-char) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3360 (skip-chars-forward " \t") |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3361 (setq placeholder (point))) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3362 (c-add-syntax 'arglist-cont-nonempty placeholder)) |
24282 | 3363 ;; CASE 7G: we are looking at just a normal arglist |
18720 | 3364 ;; continuation line |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3365 (t (c-forward-syntactic-ws indent-point) |
18720 | 3366 (c-add-syntax 'arglist-cont (c-point 'boi))) |
3367 )) | |
24282 | 3368 ;; CASE 8: func-local multi-inheritance line |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3369 ((and (c-major-mode-is 'c++-mode) |
18720 | 3370 (save-excursion |
3371 (goto-char indent-point) | |
3372 (skip-chars-forward " \t") | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3373 (looking-at c-opt-decl-spec-key))) |
18720 | 3374 (goto-char indent-point) |
3375 (skip-chars-forward " \t") | |
3376 (cond | |
24282 | 3377 ;; CASE 8A: non-hanging colon on an inher intro |
18720 | 3378 ((eq char-after-ip ?:) |
3379 (c-backward-syntactic-ws lim) | |
3380 (c-add-syntax 'inher-intro (c-point 'boi))) | |
24282 | 3381 ;; CASE 8B: hanging colon on an inher intro |
18720 | 3382 ((eq char-before-ip ?:) |
3383 (c-add-syntax 'inher-intro (c-point 'boi))) | |
24282 | 3384 ;; CASE 8C: a continued inheritance line |
18720 | 3385 (t |
3386 (c-beginning-of-inheritance-list lim) | |
3387 (c-add-syntax 'inher-cont (point)) | |
3388 ))) | |
24282 | 3389 ;; CASE 9: we are inside a brace-list |
3390 ((setq special-brace-list | |
3391 (or (and c-special-brace-lists | |
3392 (save-excursion | |
3393 (goto-char containing-sexp) | |
3394 (c-looking-at-special-brace-list))) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3395 (c-inside-bracelist-p containing-sexp paren-state))) |
18720 | 3396 (cond |
24282 | 3397 ;; CASE 9A: In the middle of a special brace list opener. |
3398 ((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
|
3399 (save-excursion |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3400 (goto-char containing-sexp) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3401 (eq (char-after) ?\()) |
24282 | 3402 (eq char-after-ip (car (cdr special-brace-list)))) |
3403 (goto-char (car (car special-brace-list))) | |
26817 | 3404 (skip-chars-backward " \t") |
36920 | 3405 (if (and (bolp) |
3406 (assoc 'statement-cont | |
3407 (setq placeholder (c-guess-basic-syntax)))) | |
3408 (setq syntax placeholder) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3409 (c-beginning-of-statement-1 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3410 (c-safe-position (1- containing-sexp) paren-state)) |
26817 | 3411 (c-forward-token-1 0) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3412 (if (looking-at "typedef\\>[^_]") (c-forward-token-1 1)) |
26817 | 3413 (c-add-syntax 'brace-list-open (c-point 'boi)))) |
24282 | 3414 ;; CASE 9B: brace-list-close brace |
3415 ((if (consp special-brace-list) | |
3416 ;; Check special brace list closer. | |
3417 (progn | |
3418 (goto-char (car (car special-brace-list))) | |
3419 (save-excursion | |
3420 (goto-char indent-point) | |
3421 (back-to-indentation) | |
3422 (or | |
3423 ;; We were between the special close char and the `)'. | |
3424 (and (eq (char-after) ?\)) | |
3425 (eq (1+ (point)) (cdr (car special-brace-list)))) | |
3426 ;; We were before the special close char. | |
3427 (and (eq (char-after) (cdr (cdr special-brace-list))) | |
3428 (= (c-forward-token-1) 0) | |
3429 (eq (1+ (point)) (cdr (car special-brace-list))))))) | |
3430 ;; Normal brace list check. | |
3431 (and (eq char-after-ip ?}) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3432 (c-safe (progn (goto-char (c-up-list-backward (point))) |
24282 | 3433 t)) |
3434 (= (point) containing-sexp))) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3435 (if (eq (point) (c-point 'boi)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3436 (c-add-syntax 'brace-list-close (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3437 (setq lim (c-most-enclosing-brace c-state-cache (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3438 (c-beginning-of-statement-1 lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3439 (c-add-stmt-syntax 'brace-list-close t lim |
45049
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
3440 (c-whack-state-after (point) paren-state) |
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
3441 t))) |
24282 | 3442 (t |
3443 ;; Prepare for the rest of the cases below by going to the | |
3444 ;; token following the opening brace | |
3445 (if (consp special-brace-list) | |
3446 (progn | |
3447 (goto-char (car (car special-brace-list))) | |
3448 (c-forward-token-1 1 nil indent-point)) | |
3449 (goto-char containing-sexp)) | |
3450 (forward-char) | |
3451 (let ((start (point))) | |
18720 | 3452 (c-forward-syntactic-ws indent-point) |
24282 | 3453 (goto-char (max start (c-point 'bol)))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3454 (c-skip-ws-forward indent-point) |
24282 | 3455 (cond |
3456 ;; CASE 9C: we're looking at the first line in a brace-list | |
3457 ((= (point) indent-point) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3458 (if (consp special-brace-list) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3459 (goto-char (car (car special-brace-list))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3460 (goto-char containing-sexp)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3461 (if (eq (point) (c-point 'boi)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3462 (c-add-syntax 'brace-list-intro (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3463 (setq lim (c-most-enclosing-brace c-state-cache (point))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3464 (c-beginning-of-statement-1 lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3465 (c-add-stmt-syntax 'brace-list-intro t lim |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3466 (c-whack-state-after (point) paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3467 t))) |
24282 | 3468 ;; CASE 9D: this is just a later brace-list-entry or |
36920 | 3469 ;; brace-entry-open |
24282 | 3470 (t (if (or (eq char-after-ip ?{) |
3471 (and c-special-brace-lists | |
3472 (save-excursion | |
3473 (goto-char indent-point) | |
3474 (c-forward-syntactic-ws (c-point 'eol)) | |
3475 (c-looking-at-special-brace-list (point))))) | |
3476 (c-add-syntax 'brace-entry-open (point)) | |
3477 (c-add-syntax 'brace-list-entry (point)) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3478 )) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3479 )))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3480 ;; CASE 10: A continued statement or top level construct. |
24282 | 3481 ((and (not (memq char-before-ip '(?\; ?:))) |
3482 (or (not (eq char-before-ip ?})) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3483 (c-looking-at-inexpr-block-backward c-state-cache)) |
18720 | 3484 (> (point) |
3485 (save-excursion | |
3486 (c-beginning-of-statement-1 containing-sexp) | |
3487 (setq placeholder (point)))) | |
3488 (/= placeholder containing-sexp)) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3489 ;; This is shared with case 18. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3490 (c-guess-continued-construct indent-point |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3491 char-after-ip |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3492 placeholder |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3493 containing-sexp |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3494 paren-state)) |
24282 | 3495 ;; CASE 14: A case or default label |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3496 ((looking-at c-label-kwds-regexp) |
18720 | 3497 (goto-char containing-sexp) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3498 (setq lim (c-most-enclosing-brace c-state-cache containing-sexp)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3499 (c-backward-to-block-anchor lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3500 (c-add-stmt-syntax 'case-label t lim paren-state)) |
24282 | 3501 ;; CASE 15: any other label |
18720 | 3502 ((looking-at c-label-key) |
3503 (goto-char containing-sexp) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3504 (setq lim (c-most-enclosing-brace c-state-cache containing-sexp)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3505 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3506 (setq tmpsymbol |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3507 (if (and (eq (c-beginning-of-statement-1 lim) 'up) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3508 (looking-at "switch\\>[^_]")) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3509 ;; If the surrounding statement is a switch then |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3510 ;; let's analyze all labels as switch labels, so |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3511 ;; that they get lined up consistently. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3512 'case-label |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3513 'label))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3514 (c-backward-to-block-anchor lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3515 (c-add-stmt-syntax tmpsymbol t lim paren-state)) |
24282 | 3516 ;; CASE 16: block close brace, possibly closing the defun or |
18720 | 3517 ;; the class |
3518 ((eq char-after-ip ?}) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3519 ;; From here on we have the next containing sexp in lim. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3520 (setq lim (c-most-enclosing-brace paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3521 (goto-char containing-sexp) |
18720 | 3522 (cond |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3523 ;; CASE 16E: Closing a statement block? This catches |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3524 ;; cases where it's preceded by a statement keyword, |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3525 ;; which works even when used in an "invalid" context, |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3526 ;; e.g. a macro argument. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3527 ((c-after-conditional) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3528 (c-backward-to-block-anchor lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3529 (c-add-stmt-syntax 'block-close t lim paren-state)) |
24282 | 3530 ;; CASE 16A: closing a lambda defun or an in-expression |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3531 ;; block? C.f. cases 4, 7B and 17E. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3532 ((setq placeholder (c-looking-at-inexpr-block |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3533 (c-safe-position containing-sexp paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3534 nil)) |
24282 | 3535 (setq tmpsymbol (if (eq (car placeholder) 'inlambda) |
3536 'inline-close | |
3537 'block-close)) | |
3538 (goto-char containing-sexp) | |
3539 (back-to-indentation) | |
3540 (if (= containing-sexp (point)) | |
3541 (c-add-syntax tmpsymbol (point)) | |
3542 (goto-char (cdr placeholder)) | |
36920 | 3543 (back-to-indentation) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3544 (c-add-stmt-syntax tmpsymbol t |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3545 (c-most-enclosing-brace paren-state (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3546 (c-whack-state-after (point) paren-state)) |
36920 | 3547 (if (/= (point) (cdr placeholder)) |
3548 (c-add-syntax (car placeholder))))) | |
24282 | 3549 ;; 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
|
3550 ;; an extern block or namespace? |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3551 ((setq placeholder (c-search-uplist-for-classkey paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3552 (c-backward-to-decl-anchor lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3553 (back-to-indentation) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3554 (if (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3555 (goto-char (aref placeholder 0)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3556 (looking-at c-other-decl-block-key)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3557 (c-add-syntax 'defun-close (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3558 (c-add-syntax 'inline-close (point)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3559 ;; CASE 16F: Can be a defun-close of a function declared |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3560 ;; in a statement block, e.g. in Pike or when using gcc |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3561 ;; extensions. Might also trigger it with some macros |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3562 ;; followed by blocks, and this gives sane indentation |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3563 ;; then too. Let it through to be handled below. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3564 ;; C.f. cases B.3 and 17G. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3565 ((and (not inenclosing-p) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3566 lim |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3567 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3568 (and (not (c-looking-at-bos)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3569 (eq (c-beginning-of-statement-1 lim nil nil t) 'same) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3570 (setq placeholder (point))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3571 (back-to-indentation) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3572 (if (/= (point) containing-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3573 (goto-char placeholder)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3574 (c-add-stmt-syntax 'defun-close t lim paren-state)) |
24282 | 3575 ;; CASE 16C: if there an enclosing brace that hasn't |
18720 | 3576 ;; been narrowed out by a class, then this is a |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3577 ;; block-close. C.f. case 17H. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3578 ((and (not inenclosing-p) lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3579 ;; If the block is preceded by a case/switch label on |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3580 ;; the same line, we anchor at the first preceding label |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3581 ;; at boi. The default handling in c-add-stmt-syntax is |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3582 ;; really fixes it better, but we do like this to keep |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3583 ;; the indentation compatible with version 5.28 and |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3584 ;; earlier. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3585 (while (and (/= (setq placeholder (point)) (c-point 'boi)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3586 (eq (c-beginning-of-statement-1 lim) 'label))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3587 (goto-char placeholder) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3588 (if (looking-at c-label-kwds-regexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3589 (c-add-syntax 'block-close (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3590 (goto-char containing-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3591 ;; c-backward-to-block-anchor not necessary here; those |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3592 ;; situations are handled in case 16E above. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3593 (c-add-stmt-syntax 'block-close t lim paren-state))) |
24282 | 3594 ;; CASE 16D: find out whether we're closing a top-level |
18720 | 3595 ;; class or a defun |
3596 (t | |
3597 (save-restriction | |
3598 (narrow-to-region (point-min) indent-point) | |
3599 (let ((decl (c-search-uplist-for-classkey (c-parse-state)))) | |
3600 (if decl | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3601 (c-add-class-syntax 'class-close decl paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3602 (goto-char containing-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3603 (c-backward-to-decl-anchor lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3604 (back-to-indentation) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3605 (c-add-syntax 'defun-close (point))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3606 ))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3607 ;; CASE 17: Statement or defun catchall. |
18720 | 3608 (t |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3609 (goto-char indent-point) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3610 ;; Back up statements until we find one that starts at boi. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3611 (while (let* ((prev-point (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3612 (last-step-type (c-beginning-of-statement-1 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3613 containing-sexp))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3614 (if (= (point) prev-point) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3615 (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3616 (setq step-type (or step-type last-step-type)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3617 nil) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3618 (setq step-type last-step-type) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3619 (/= (point) (c-point 'boi))))) |
18720 | 3620 (cond |
24282 | 3621 ;; CASE 17B: continued statement |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3622 ((and (eq step-type 'same) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3623 (/= (point) indent-point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3624 (c-add-stmt-syntax 'statement-cont nil |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3625 containing-sexp paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3626 ;; CASE 17A: After a case/default label? |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3627 ((progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3628 (while (and (eq step-type 'label) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3629 (not (looking-at c-label-kwds-regexp))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3630 (setq step-type |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3631 (c-beginning-of-statement-1 containing-sexp))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3632 (eq step-type 'label)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3633 (c-add-stmt-syntax (if (eq char-after-ip ?{) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3634 'statement-case-open |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3635 'statement-case-intro) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3636 t containing-sexp paren-state)) |
24282 | 3637 ;; CASE 17D: any old statement |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3638 ((progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3639 (while (eq step-type 'label) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3640 (setq step-type |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3641 (c-beginning-of-statement-1 containing-sexp))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3642 (eq step-type 'previous)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3643 (c-add-stmt-syntax 'statement t containing-sexp paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3644 (if (eq char-after-ip ?{) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3645 (c-add-syntax 'block-open))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3646 ;; CASE 17I: Inside a substatement block. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3647 ((progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3648 ;; The following tests are all based on containing-sexp. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3649 (goto-char containing-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3650 ;; From here on we have the next containing sexp in lim. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3651 (setq lim (c-most-enclosing-brace paren-state containing-sexp)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3652 (c-after-conditional)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3653 (c-backward-to-block-anchor lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3654 (c-add-stmt-syntax 'statement-block-intro t lim paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3655 (if (eq char-after-ip ?{) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3656 (c-add-syntax 'block-open))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3657 ;; CASE 17E: first statement in an in-expression block. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3658 ;; C.f. cases 4, 7B and 16A. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3659 ((setq placeholder (c-looking-at-inexpr-block |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3660 (c-safe-position containing-sexp paren-state) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3661 nil)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3662 (setq tmpsymbol (if (eq (car placeholder) 'inlambda) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3663 'defun-block-intro |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3664 'statement-block-intro)) |
24282 | 3665 (back-to-indentation) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3666 (if (= containing-sexp (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3667 (c-add-syntax tmpsymbol (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3668 (goto-char (cdr placeholder)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3669 (back-to-indentation) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3670 (c-add-stmt-syntax tmpsymbol t |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3671 (c-most-enclosing-brace c-state-cache (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3672 (c-whack-state-after (point) paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3673 (if (/= (point) (cdr placeholder)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3674 (c-add-syntax (car placeholder)))) |
24282 | 3675 (if (eq char-after-ip ?{) |
3676 (c-add-syntax 'block-open))) | |
3677 ;; CASE 17F: first statement in an inline, or first | |
18720 | 3678 ;; statement in a top-level defun. we can tell this is it |
3679 ;; if there are no enclosing braces that haven't been | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3680 ;; narrowed out by a class (i.e. don't use bod here). |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3681 ;; However, we first check for statements that we can |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3682 ;; recognize by keywords. That increases the robustness in |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3683 ;; cases where statements are used on the top level, |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3684 ;; e.g. in macro definitions. |
18720 | 3685 ((save-excursion |
3686 (save-restriction | |
3687 (widen) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3688 (c-narrow-out-enclosing-class paren-state containing-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3689 (not (c-most-enclosing-brace paren-state)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3690 (c-backward-to-decl-anchor lim) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3691 (back-to-indentation) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3692 (c-add-syntax 'defun-block-intro (point))) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3693 ;; CASE 17G: First statement in a function declared inside |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3694 ;; a normal block. This can occur in Pike and with |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3695 ;; e.g. the gcc extensions. Might also trigger it with |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3696 ;; some macros followed by blocks, and this gives sane |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3697 ;; indentation then too. C.f. cases B.3 and 16F. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3698 ((save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3699 (and (not (c-looking-at-bos)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3700 (eq (c-beginning-of-statement-1 lim nil nil t) 'same) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3701 (setq placeholder (point)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3702 (back-to-indentation) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3703 (if (/= (point) containing-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3704 (goto-char placeholder)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3705 (c-add-stmt-syntax 'defun-block-intro t lim paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3706 ;; CASE 17H: First statement in a block. C.f. case 16C. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3707 (t |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3708 ;; If the block is preceded by a case/switch label on the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3709 ;; same line, we anchor at the first preceding label at |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3710 ;; boi. The default handling in c-add-stmt-syntax is |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3711 ;; really fixes it better, but we do like this to keep the |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3712 ;; indentation compatible with version 5.28 and earlier. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3713 (while (and (/= (setq placeholder (point)) (c-point 'boi)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3714 (eq (c-beginning-of-statement-1 lim) 'label))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3715 (goto-char placeholder) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3716 (if (looking-at c-label-kwds-regexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3717 (c-add-syntax 'statement-block-intro (point)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3718 (goto-char containing-sexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3719 ;; c-backward-to-block-anchor not necessary here; those |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3720 ;; situations are handled in case 17I above. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3721 (c-add-stmt-syntax 'statement-block-intro t lim paren-state)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3722 (if (eq char-after-ip ?{) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3723 (c-add-syntax 'block-open))) |
18720 | 3724 )) |
3725 ) | |
3726 ;; now we need to look at any modifiers | |
3727 (goto-char indent-point) | |
3728 (skip-chars-forward " \t") | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3729 ;; are we looking at a comment only line? |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3730 (when (and (looking-at c-comment-start-regexp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3731 (/= (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
|
3732 (c-add-syntax 'comment-intro)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3733 ;; we might want to give additional offset to friends (in C++). |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3734 (when (and c-opt-friend-key |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3735 (looking-at c-opt-friend-key)) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
3736 (c-add-syntax 'friend)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3737 ;; Start of or a continuation of a preprocessor directive? |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3738 (if (and macro-start |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3739 (eq macro-start (c-point 'boi)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3740 (not (and (c-major-mode-is 'pike-mode) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3741 (eq (char-after (1+ macro-start)) ?\")))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3742 (c-add-syntax 'cpp-macro) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3743 (when (and c-syntactic-indentation-in-macros macro-start) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3744 (if in-macro-expr |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3745 (when (or (< syntactic-relpos macro-start) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3746 (not (or (assq 'arglist-intro syntax) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3747 (assq 'arglist-cont syntax) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3748 (assq 'arglist-cont-nonempty syntax) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3749 (assq 'arglist-close syntax)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3750 ;; If inside a cpp expression, i.e. anywhere in a |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3751 ;; cpp directive except a #define body, we only let |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3752 ;; through the syntactic analysis that is internal |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3753 ;; in the expression. That means the arglist |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3754 ;; elements, if they are anchored inside the cpp |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3755 ;; expression. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3756 (setq syntax `((cpp-macro-cont . ,macro-start)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3757 (when (and (eq macro-start syntactic-relpos) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3758 (not (assq 'cpp-define-intro syntax)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3759 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3760 (goto-char macro-start) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3761 (or (not (c-forward-to-cpp-define-body)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3762 (<= (point) (c-point 'boi indent-point))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3763 ;; Inside a #define body and the syntactic analysis is |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3764 ;; anchored on the start of the #define. In this case |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3765 ;; we add cpp-define-intro to get the extra |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3766 ;; indentation of the #define body. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3767 (c-add-syntax 'cpp-define-intro))))) |
18720 | 3768 ;; return the syntax |
3769 syntax)))) | |
3770 | |
3771 | |
36920 | 3772 (defun c-echo-parsing-error (&optional quiet) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3773 (when (and c-report-syntactic-errors c-parsing-error (not quiet)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3774 (c-benign-error "%s" c-parsing-error)) |
18720 | 3775 c-parsing-error) |
3776 | |
36920 | 3777 (defun c-evaluate-offset (offset langelem symbol) |
3778 ;; offset can be a number, a function, a variable, a list, or one of | |
3779 ;; the symbols + or - | |
3780 (cond | |
3781 ((eq offset '+) c-basic-offset) | |
3782 ((eq offset '-) (- c-basic-offset)) | |
3783 ((eq offset '++) (* 2 c-basic-offset)) | |
3784 ((eq offset '--) (* 2 (- c-basic-offset))) | |
3785 ((eq offset '*) (/ c-basic-offset 2)) | |
3786 ((eq offset '/) (/ (- c-basic-offset) 2)) | |
3787 ((numberp offset) offset) | |
3788 ((functionp offset) (c-evaluate-offset | |
3789 (funcall offset langelem) langelem symbol)) | |
3790 ((vectorp offset) offset) | |
3791 ((null offset) nil) | |
3792 ((listp offset) | |
3793 (let (done) | |
3794 (while (and (not done) offset) | |
3795 (setq done (c-evaluate-offset (car offset) langelem symbol) | |
3796 offset (cdr offset))) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3797 (if (and c-strict-syntax-p (not done)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3798 (c-benign-error "No offset found for syntactic symbol %s" symbol)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3799 done)) |
36920 | 3800 (t (symbol-value offset)) |
3801 )) | |
3802 | |
3803 (defun c-get-offset (langelem) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3804 "Get offset from LANGELEM which is a cons cell of the form: |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3805 \(SYMBOL . RELPOS). The symbol is matched against `c-offsets-alist' |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3806 and the offset found there is returned." |
36920 | 3807 (let* ((symbol (car langelem)) |
3808 (match (assq symbol c-offsets-alist)) | |
3809 (offset (cdr-safe match))) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3810 (if match |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3811 (setq offset (c-evaluate-offset offset langelem symbol)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3812 (if c-strict-syntax-p |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3813 (c-benign-error "No offset found for syntactic symbol %s" symbol)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3814 (setq offset 0)) |
36920 | 3815 (if (vectorp offset) |
3816 offset | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3817 (or (and (numberp offset) offset) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3818 (and (symbolp offset) (symbol-value offset)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3819 0)) |
36920 | 3820 )) |
3821 | |
3822 (defun c-get-syntactic-indentation (langelems) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3823 "Apply `c-get-offset' to a list of langelem cells to get the total |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3824 syntactic indentation. The anchor position, whose column is used as a |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3825 base for all the collected offsets, is taken from the first element |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3826 with a relpos." |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3827 ;; Note that topmost-intro always has a relpos at bol, for |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3828 ;; historical reasons. It's often used together with other symbols |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3829 ;; that has more sane positions. Since we always use the first |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3830 ;; found relpos, we rely on that these other symbols always precede |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3831 ;; topmost-intro in the LANGELEMS list. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3832 (let ((indent 0) anchor) |
36920 | 3833 (catch 'done |
3834 (while langelems | |
3835 (let ((res (c-get-offset (car langelems)))) | |
3836 (if (vectorp res) | |
3837 (throw 'done (elt res 0)) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3838 (unless anchor |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3839 (let ((relpos (cdr (car langelems)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3840 (if relpos |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3841 (setq anchor relpos)))) |
36920 | 3842 (setq indent (+ indent res) |
3843 langelems (cdr langelems))))) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3844 (+ indent |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3845 (if anchor |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3846 (save-excursion |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3847 (goto-char anchor) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3848 (current-column)) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
3849 0))))) |
26817 | 3850 |
18720 | 3851 |
36920 | 3852 (cc-provide 'cc-engine) |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
3853 |
18720 | 3854 ;;; cc-engine.el ends here |