Mercurial > emacs
annotate lisp/progmodes/cc-engine.el @ 62372:4560134d21fa
(open-network-stream-nowait): Remove.
(open-network-stream-server): Remove.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Sun, 15 May 2005 20:42:43 +0000 |
parents | 3ae147d964be |
children | 27b53b1903b6 f042e7c0fe20 |
rev | line source |
---|---|
18720 | 1 ;;; cc-engine.el --- core syntax guessing engine for CC mode |
2 | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3 ;; Copyright (C) 1985,1987,1992-2003 Free Software Foundation, Inc. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5 ;; Authors: 1998- Martin Stjernholm |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6 ;; 1992-1999 Barry A. Warsaw |
18720 | 7 ;; 1987 Dave Detlefs and Stewart Clamen |
8 ;; 1985 Richard M. Stallman | |
24282 | 9 ;; Maintainer: bug-cc-mode@gnu.org |
18720 | 10 ;; Created: 22-Apr-1997 (split from cc-mode.el) |
20142 | 11 ;; Version: See cc-mode.el |
18720 | 12 ;; Keywords: c languages oop |
13 | |
14 ;; This file is part of GNU Emacs. | |
15 | |
16 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
17 ;; it under the terms of the GNU General Public License as published by | |
18 ;; the Free Software Foundation; either version 2, or (at your option) | |
19 ;; any later version. | |
20 | |
21 ;; GNU Emacs is distributed in the hope that it will be useful, | |
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
24 ;; GNU General Public License for more details. | |
25 | |
26 ;; 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
|
27 ;; along with GNU Emacs; see the file COPYING. If not, write to |
36920 | 28 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18720 | 29 ;; Boston, MA 02111-1307, USA. |
30 | |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
31 ;;; Commentary: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
32 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
33 ;; 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
|
34 ;; 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
|
35 ;; 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
|
36 ;; 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
|
37 ;; 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
|
38 ;; |
7a3ac6c387fe
CC Mode 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 ;; (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
|
40 ;; 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
|
41 ;; 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
|
42 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
43 ;; Hidden buffer changes |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
44 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
45 ;; Various functions in CC Mode use text properties for caching and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
46 ;; syntactic markup purposes, and those of them that might modify such |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
47 ;; properties are said to do "hidden buffer changes". They should be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
48 ;; used within `c-save-buffer-state' or a similar function that saves |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
49 ;; and restores buffer modifiedness etc. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
50 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
51 ;; Interactive functions are assumed to not do hidden buffer changes |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
52 ;; (this isn't applicable in the specific parts of them that do real |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
53 ;; changes, though). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
54 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
55 ;; All other functions are assumed to do hidden buffer changes and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
56 ;; must thus be wrapped inside `c-save-buffer-state' if they're used |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
57 ;; from any function that does not do hidden buffer changes. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
58 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
59 ;; Every function, except the interactive ones, that doesn't do hidden |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
60 ;; buffer changes have that explicitly stated in their docstring or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
61 ;; comment. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
62 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
63 ;; Use of text properties |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
64 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
65 ;; CC Mode uses several text properties internally to mark up various |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
66 ;; positions, e.g. to improve speed and to eliminate glitches in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
67 ;; interactive refontification. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
68 ;; |
51829
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
69 ;; Note: This doc is for internal use only. Other packages should not |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
70 ;; assume that these text properties are used as described here. |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
71 ;; |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
72 ;; 'syntax-table |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
73 ;; Used to modify the syntax of some characters. Currently used to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
74 ;; mark the "<" and ">" of angle bracket parens with paren syntax. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
75 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
76 ;; This property is used on single characters and is therefore |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
77 ;; always treated as front and rear nonsticky (or start and end open |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
78 ;; in XEmacs vocabulary). It's therefore installed on |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
79 ;; `text-property-default-nonsticky' if that variable exists (Emacs |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
80 ;; >= 21). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
81 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
82 ;; 'c-is-sws and 'c-in-sws |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
83 ;; Used by `c-forward-syntactic-ws' and `c-backward-syntactic-ws' to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
84 ;; speed them up. See the comment blurb before `c-put-is-sws' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
85 ;; below for further details. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
86 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
87 ;; 'c-type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
88 ;; This property is used on single characters to mark positions with |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
89 ;; special syntactic relevance of various sorts. It's primary use |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
90 ;; is to avoid glitches when multiline constructs are refontified |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
91 ;; interactively (on font lock decoration level 3). It's cleared in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
92 ;; a region before it's fontified and is then put on relevant chars |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
93 ;; in that region as they are encountered during the fontification. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
94 ;; The value specifies the kind of position: |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
95 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
96 ;; 'c-decl-arg-start |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
97 ;; Put on the last char of the token preceding each declaration |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
98 ;; inside a declaration style arglist (typically in a function |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
99 ;; prototype). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
100 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
101 ;; 'c-decl-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
102 ;; Put on the last char of the token preceding a declaration. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
103 ;; This is used in cases where declaration boundaries can't be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
104 ;; recognized simply by looking for a token like ";" or "}". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
105 ;; `c-type-decl-end-used' must be set if this is used (see also |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
106 ;; `c-find-decl-spots'). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
107 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
108 ;; 'c-<>-arg-sep |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
109 ;; Put on the commas that separate arguments in angle bracket |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
110 ;; arglists like C++ template arglists. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
111 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
112 ;; 'c-decl-id-start and 'c-decl-type-start |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
113 ;; Put on the last char of the token preceding each declarator |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
114 ;; in the declarator list of a declaration. They are also used |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
115 ;; between the identifiers cases like enum declarations. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
116 ;; 'c-decl-type-start is used when the declarators are types, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
117 ;; 'c-decl-id-start otherwise. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
118 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
119 ;; 'c-awk-NL-prop |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
120 ;; Used in AWK mode to mark the various kinds of newlines. See |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
121 ;; cc-awk.el. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
122 |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
123 ;;; Code: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
124 |
26817 | 125 (eval-when-compile |
126 (let ((load-path | |
36920 | 127 (if (and (boundp 'byte-compile-dest-file) |
128 (stringp byte-compile-dest-file)) | |
129 (cons (file-name-directory byte-compile-dest-file) load-path) | |
26817 | 130 load-path))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
131 (load "cc-bytecomp" nil t))) |
36920 | 132 |
133 (cc-require 'cc-defs) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
134 (cc-require-when-compile 'cc-langs) |
36920 | 135 (cc-require 'cc-vars) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
136 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
137 ;; Some functions/constants in cc-awk.el that are called/referenced here. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
138 ;; (Can't use cc-require due to cyclicity.) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
139 (cc-bytecomp-defun c-awk-unstick-NL-prop) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
140 (cc-bytecomp-defun c-awk-clear-NL-props) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
141 (cc-bytecomp-defvar awk-mode-syntax-table) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
142 (cc-bytecomp-defun c-awk-backward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
143 (cc-bytecomp-defun c-awk-after-logical-semicolon) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
144 (cc-bytecomp-defun c-awk-NL-prop-not-set) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
145 (cc-bytecomp-defun c-awk-completed-stmt-ws-ends-line-p) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
146 (cc-bytecomp-defun c-awk-completed-stmt-ws-ends-prev-line-p) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
147 (cc-bytecomp-defun c-awk-prev-line-incomplete-p) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
148 (cc-bytecomp-defun c-awk-after-change) |
36920 | 149 |
150 ;; Silence the compiler. | |
151 (cc-bytecomp-defun buffer-syntactic-context) ; XEmacs | |
26817 | 152 |
18720 | 153 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
154 ;; Make declarations for all the `c-lang-defvar' variables in cc-langs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
155 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
156 (defmacro c-declare-lang-variables () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
157 `(progn |
51888
b5a29d6f2851
(c-declare-lang-variables): Don't use mapcan.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
158 ,@(apply 'nconc |
b5a29d6f2851
(c-declare-lang-variables): Don't use mapcan.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
159 (mapcar (lambda (init) |
b5a29d6f2851
(c-declare-lang-variables): Don't use mapcan.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
160 `(,(if (elt init 2) |
b5a29d6f2851
(c-declare-lang-variables): Don't use mapcan.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
161 `(defvar ,(car init) nil ,(elt init 2)) |
b5a29d6f2851
(c-declare-lang-variables): Don't use mapcan.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
162 `(defvar ,(car init) nil)) |
b5a29d6f2851
(c-declare-lang-variables): Don't use mapcan.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
163 (make-variable-buffer-local ',(car init)))) |
b5a29d6f2851
(c-declare-lang-variables): Don't use mapcan.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
164 (cdr c-lang-variable-inits))))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
165 (c-declare-lang-variables) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
166 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
167 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
168 ;;; Internal state variables. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
169 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
170 ;; Internal state of hungry delete key feature |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
171 (defvar c-hungry-delete-key nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
172 (make-variable-buffer-local 'c-hungry-delete-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
173 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
174 ;; Internal state of auto newline feature. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
175 (defvar c-auto-newline nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
176 (make-variable-buffer-local 'c-auto-newline) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
177 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
178 ;; Internal auto-newline/hungry-delete designation string for mode line. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
179 (defvar c-auto-hungry-string nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
180 (make-variable-buffer-local 'c-auto-hungry-string) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
181 |
44728
7a3ac6c387fe
CC Mode 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 (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
|
183 ;; 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
|
184 ;; 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
|
185 ;; 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
|
186 (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
|
187 (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
|
188 (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
|
189 (> 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
|
190 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
191 ;; Dynamically bound cache for `c-in-literal'. |
36920 | 192 (defvar c-in-literal-cache t) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
193 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
194 ;; Must be set in buffers where the `c-type' text property might be used |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
195 ;; with the value `c-decl-end'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
196 (defvar c-type-decl-end-used nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
197 (make-variable-buffer-local 'c-type-decl-end-used) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
198 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
199 |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
200 ;; Basic handling of preprocessor directives. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
201 |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
202 ;; This is a dynamically bound cache used together with |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
203 ;; `c-query-macro-start' and `c-query-and-set-macro-start'. It only |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
204 ;; works as long as point doesn't cross a macro boundary. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
205 (defvar c-macro-start 'unknown) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
206 |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
207 (defsubst c-query-and-set-macro-start () |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
208 ;; This function does not do any hidden buffer changes. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
209 (if (symbolp c-macro-start) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
210 (setq c-macro-start (save-excursion |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
211 (and (c-beginning-of-macro) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
212 (point)))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
213 c-macro-start)) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
214 |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
215 (defsubst c-query-macro-start () |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
216 ;; This function does not do any hidden buffer changes. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
217 (if (symbolp c-macro-start) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
218 (save-excursion |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
219 (and (c-beginning-of-macro) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
220 (point))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
221 c-macro-start)) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
222 |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
223 (defun c-beginning-of-macro (&optional lim) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
224 "Go to the beginning of a preprocessor directive. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
225 Leave point at the beginning of the directive and return t if in one, |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
226 otherwise return nil and leave point unchanged. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
227 |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
228 This function does not do any hidden buffer changes." |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
229 (when c-opt-cpp-prefix |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
230 (let ((here (point))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
231 (save-restriction |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
232 (if lim (narrow-to-region lim (point-max))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
233 (beginning-of-line) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
234 (while (eq (char-before (1- (point))) ?\\) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
235 (forward-line -1)) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
236 (back-to-indentation) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
237 (if (and (<= (point) here) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
238 (looking-at c-opt-cpp-start)) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
239 t |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
240 (goto-char here) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
241 nil))))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
242 |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
243 (defun c-end-of-macro () |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
244 "Go to the end of a preprocessor directive. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
245 More accurately, move point to the end of the closest following line |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
246 that doesn't end with a line continuation backslash. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
247 |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
248 This function does not do any hidden buffer changes." |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
249 (while (progn |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
250 (end-of-line) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
251 (when (and (eq (char-before) ?\\) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
252 (not (eobp))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
253 (forward-char) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
254 t)))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
255 |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
256 (defun c-forward-to-cpp-define-body () |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
257 ;; Assuming point is at the "#" that introduces a preprocessor |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
258 ;; directive, it's moved forward to the start of the definition body |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
259 ;; if it's a "#define". Non-nil is returned in this case, in all |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
260 ;; other cases nil is returned and point isn't moved. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
261 (when (and (looking-at |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
262 (concat "#[ \t]*" |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
263 "define[ \t]+\\(\\sw\\|_\\)+\\(\([^\)]*\)\\)?" |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
264 "\\([ \t]\\|\\\\\n\\)*")) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
265 (not (= (match-end 0) (c-point 'eol)))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
266 (goto-char (match-end 0)))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
267 |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
268 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
269 ;;; Basic utility functions. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
270 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
271 (defun c-syntactic-content (from to) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
272 ;; Return the given region as a string where all syntactic |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
273 ;; whitespace is removed or, where necessary, replaced with a single |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
274 ;; space. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
275 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
276 (goto-char from) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
277 (let* ((parts (list nil)) (tail parts) pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
278 (while (re-search-forward c-syntactic-ws-start to t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
279 (goto-char (setq pos (match-beginning 0))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
280 (c-forward-syntactic-ws to) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
281 (if (= (point) pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
282 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
283 (if (and (> pos from) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
284 (< (point) to) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
285 (looking-at "\\w\\|\\s_") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
286 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
287 (goto-char (1- pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
288 (looking-at "\\w\\|\\s_"))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
289 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
290 (setcdr tail (list (buffer-substring-no-properties from pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
291 " ")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
292 (setq tail (cddr tail))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
293 (setcdr tail (list (buffer-substring-no-properties from pos))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
294 (setq tail (cdr tail))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
295 (setq from (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
296 (setcdr tail (list (buffer-substring-no-properties from to))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
297 (apply 'concat (cdr parts))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
298 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
299 (defsubst c-keyword-sym (keyword) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
300 ;; Return non-nil if the string KEYWORD is a known keyword. More |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
301 ;; precisely, the value is the symbol for the keyword in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
302 ;; `c-keywords-obarray'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
303 (intern-soft keyword c-keywords-obarray)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
304 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
305 (defsubst c-keyword-member (keyword-sym lang-constant) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
306 ;; Return non-nil if the symbol KEYWORD-SYM, as returned by |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
307 ;; `c-keyword-sym', is a member of LANG-CONSTANT, which is the name |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
308 ;; of a language constant that ends with "-kwds". If KEYWORD-SYM is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
309 ;; nil then the result is nil. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
310 (get keyword-sym lang-constant)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
311 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
312 ;; String syntax chars, suitable for skip-syntax-(forward|backward). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
313 (defconst c-string-syntax (if (memq 'gen-string-delim c-emacs-features) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
314 "\"|" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
315 "\"")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
316 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
317 ;; Regexp matching string start syntax. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
318 (defconst c-string-limit-regexp (if (memq 'gen-string-delim c-emacs-features) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
319 "\\s\"\\|\\s|" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
320 "\\s\"")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
321 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
322 ;; Holds formatted error strings for the few cases where parse errors |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
323 ;; are reported. |
44728
7a3ac6c387fe
CC Mode 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 (defvar c-parsing-error nil) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
325 (make-variable-buffer-local 'c-parsing-error) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
326 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
327 (defun c-echo-parsing-error (&optional quiet) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
328 ;; This function does not do any hidden buffer changes. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
329 (when (and c-report-syntactic-errors c-parsing-error (not quiet)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
330 (c-benign-error "%s" c-parsing-error)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
331 c-parsing-error) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
332 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
333 ;; Faces given to comments and string literals. This is used in some |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
334 ;; situations to speed up recognition; it isn't mandatory that font |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
335 ;; locking is in use. This variable is extended with the face in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
336 ;; `c-doc-face-name' when fontification is activated in cc-fonts.el. |
51947
668a21083a47
(c-literal-faces): Declare as a variable since it might be modified.
Martin Stjernholm <mast@lysator.liu.se>
parents:
51888
diff
changeset
|
337 (defvar c-literal-faces |
62317
3ae147d964be
(c-literal-faces): Add font-lock-comment-delimiter-face.
Richard M. Stallman <rms@gnu.org>
parents:
56646
diff
changeset
|
338 '(font-lock-comment-face font-lock-string-face |
3ae147d964be
(c-literal-faces): Add font-lock-comment-delimiter-face.
Richard M. Stallman <rms@gnu.org>
parents:
56646
diff
changeset
|
339 font-lock-comment-delimiter-face)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
340 |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
341 (defun c-shift-line-indentation (shift-amt) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
342 ;; This function does not do any hidden buffer changes. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
343 (let ((pos (- (point-max) (point))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
344 (c-macro-start c-macro-start) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
345 tmp-char-inserted) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
346 (if (zerop shift-amt) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
347 nil |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
348 (when (and (c-query-and-set-macro-start) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
349 (looking-at "[ \t]*\\\\$") |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
350 (save-excursion |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
351 (skip-chars-backward " \t") |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
352 (bolp))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
353 (insert ?x) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
354 (backward-char) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
355 (setq tmp-char-inserted t)) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
356 (unwind-protect |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
357 (let ((col (current-indentation))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
358 (delete-region (c-point 'bol) (c-point 'boi)) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
359 (beginning-of-line) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
360 (indent-to (+ col shift-amt))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
361 (when tmp-char-inserted |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
362 (delete-char 1)))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
363 ;; If initial point was within line's indentation and we're not on |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
364 ;; a line with a line continuation in a macro, position after the |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
365 ;; indentation. Else stay at same point in text. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
366 (if (and (< (point) (c-point 'boi)) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
367 (not tmp-char-inserted)) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
368 (back-to-indentation) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
369 (if (> (- (point-max) pos) (point)) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
370 (goto-char (- (point-max) pos)))))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
371 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
372 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
373 ;; Some debug tools to visualize various special positions. This |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
374 ;; debug code isn't as portable as the rest of CC Mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
375 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
376 (cc-bytecomp-defun overlays-in) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
377 (cc-bytecomp-defun overlay-get) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
378 (cc-bytecomp-defun overlay-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
379 (cc-bytecomp-defun overlay-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
380 (cc-bytecomp-defun delete-overlay) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
381 (cc-bytecomp-defun overlay-put) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
382 (cc-bytecomp-defun make-overlay) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
383 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
384 (defun c-debug-add-face (beg end face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
385 (c-save-buffer-state ((overlays (overlays-in beg end)) overlay) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
386 (while overlays |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
387 (setq overlay (car overlays) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
388 overlays (cdr overlays)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
389 (when (eq (overlay-get overlay 'face) face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
390 (setq beg (min beg (overlay-start overlay)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
391 end (max end (overlay-end overlay))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
392 (delete-overlay overlay))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
393 (overlay-put (make-overlay beg end) 'face face))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
394 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
395 (defun c-debug-remove-face (beg end face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
396 (c-save-buffer-state ((overlays (overlays-in beg end)) overlay |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
397 (ol-beg beg) (ol-end end)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
398 (while overlays |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
399 (setq overlay (car overlays) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
400 overlays (cdr overlays)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
401 (when (eq (overlay-get overlay 'face) face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
402 (setq ol-beg (min ol-beg (overlay-start overlay)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
403 ol-end (max ol-end (overlay-end overlay))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
404 (delete-overlay overlay))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
405 (when (< ol-beg beg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
406 (overlay-put (make-overlay ol-beg beg) 'face face)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
407 (when (> ol-end end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
408 (overlay-put (make-overlay end ol-end) 'face face)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
409 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
410 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
411 ;; `c-beginning-of-statement-1' and accompanying stuff. |
36920 | 412 |
18844
6b269c4ad2eb
(c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
413 ;; 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
|
414 ;; 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
|
415 ;; 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
|
416 ;; the byte compiler. |
6b269c4ad2eb
(c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
417 (defvar c-maybe-labelp nil) |
6b269c4ad2eb
(c-maybe-labelp): Add defvar.
Richard M. Stallman <rms@gnu.org>
parents:
18720
diff
changeset
|
418 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
419 ;; New awk-compatible version of c-beginning-of-statement-1, ACM 2002/6/22 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
420 |
44728
7a3ac6c387fe
CC Mode 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 ;; 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
|
422 ;; 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
|
423 (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
|
424 '(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
|
425 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
|
426 (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
|
427 `(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
|
428 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
|
429 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
|
430 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
|
431 ,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
|
432 (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
|
433 (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
|
434 '(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
|
435 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
|
436 ;; 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
|
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 (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
|
439 '(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
|
440 (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
|
441 '(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
|
442 (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
|
443 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
|
444 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
|
445 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
|
446 (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
|
447 (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
|
448 (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
|
449 `(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
|
450 (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
|
451 '(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
|
452 (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
|
453 (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
|
454 (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
|
455 (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
|
456 (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
|
457 (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
|
458 |
7a3ac6c387fe
CC Mode 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 (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
|
460 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
|
461 "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
|
462 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
|
463 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
|
464 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
|
465 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
466 Stop at statement continuation tokens like \"else\", \"catch\", |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
467 \"finally\" and the \"while\" in \"do ... while\" if the start point |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
468 is within the continuation. If starting at such a token, move to the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
469 corresponding statement start. If at the beginning of a statement, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
470 move to the closest containing statement if there is any. This might |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
471 also stop at a continuation clause. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
472 |
7a3ac6c387fe
CC Mode 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 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
|
474 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
|
475 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
|
476 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
|
477 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
|
478 |
7a3ac6c387fe
CC Mode 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 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
|
480 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
|
481 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
|
482 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
|
483 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
|
484 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
|
485 |
7a3ac6c387fe
CC Mode 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 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
|
487 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
|
488 '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
|
489 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
|
490 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
|
491 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
|
492 |
7a3ac6c387fe
CC Mode 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 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
|
494 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
|
495 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
|
496 |
7a3ac6c387fe
CC Mode 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 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
|
498 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
499 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
|
500 COMMA-DELIM is non-nil then ',' is treated likewise." |
18720 | 501 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
502 ;; The bulk of this function is a pushdown automaton that looks at statement |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
503 ;; boundaries and the tokens (such as "while") in c-opt-block-stmt-key. Its |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
504 ;; purpose is to keep track of nested statements, ensuring that such |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
505 ;; statments are skipped over in their entirety (somewhat akin to what C-M-p |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
506 ;; does with nested braces/brackets/parentheses). |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
507 ;; |
7a3ac6c387fe
CC Mode 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 ;; 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
|
509 ;; |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
510 ;; Beginning with the current token (the one following point), move back one |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
511 ;; sexp at a time (where a sexp is, more or less, either a token or the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
512 ;; entire contents of a brace/bracket/paren pair). Each time a statement |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
513 ;; boundary is crossed or a "while"-like token is found, update the state of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
514 ;; the PDA. Stop at the beginning of a statement when the stack (holding |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
515 ;; nested statement info) is empty and the position has been moved. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
516 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
517 ;; The following variables constitute the PDA: |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
518 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
519 ;; sym: This is either the "while"-like token (e.g. 'for) we've just |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
520 ;; scanned back over, 'boundary if we've just gone back over a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
521 ;; statement boundary, or nil otherwise. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
522 ;; state: takes one of the values (nil else else-boundary while |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
523 ;; while-boundary catch catch-boundary). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
524 ;; nil means "no "while"-like token yet scanned". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
525 ;; 'else, for example, means "just gone back over an else". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
526 ;; 'else-boundary means "just gone back over a statement boundary |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
527 ;; immediately after having gone back over an else". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
528 ;; saved-pos: A vector of either saved positions (tok ptok pptok, etc.) or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
529 ;; of error reporting information. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
530 ;; stack: The stack onto which the PDA pushes its state. Each entry |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
531 ;; consists of a saved value of state and saved-pos. An entry is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
532 ;; pushed when we move back over a "continuation" token (e.g. else) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
533 ;; and popped when we encounter the corresponding opening token |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
534 ;; (e.g. if). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
535 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
536 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
537 ;; The following diagram briefly outlines the PDA. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
538 ;; |
7a3ac6c387fe
CC Mode 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 ;; Common state: |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
540 ;; "else": Push state, goto state `else'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
541 ;; "while": Push state, goto state `while'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
542 ;; "catch" or "finally": Push state, goto state `catch'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
543 ;; boundary: Pop state. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
544 ;; 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
|
545 ;; |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
546 ;; State `else': |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
547 ;; boundary: Goto state `else-boundary'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
548 ;; other: Error, pop state, retry token. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
549 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
550 ;; State `else-boundary': |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
551 ;; "if": Pop state. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
552 ;; boundary: Error, pop state. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
553 ;; other: See common state. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
554 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
555 ;; State `while': |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
556 ;; boundary: Save position, goto state `while-boundary'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
557 ;; other: Pop state, retry token. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
558 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
559 ;; State `while-boundary': |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
560 ;; "do": Pop state. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
561 ;; boundary: Restore position if it's not at start, pop state. [*see below] |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
562 ;; other: See common state. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
563 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
564 ;; State `catch': |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
565 ;; boundary: Goto state `catch-boundary'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
566 ;; other: Error, pop state, retry token. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
567 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
568 ;; State `catch-boundary': |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
569 ;; "try": Pop state. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
570 ;; "catch": Goto state `catch'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
571 ;; boundary: Error, pop state. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
572 ;; other: See common state. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
573 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
574 ;; [*] In the `while-boundary' state, we had pushed a 'while state, and were |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
575 ;; searching for a "do" which would have opened a do-while. If we didn't |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
576 ;; find it, we discard the analysis done since the "while", go back to this |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
577 ;; token in the buffer and restart the scanning there, this time WITHOUT |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
578 ;; pushing the 'while state onto the stack. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
579 ;; |
44728
7a3ac6c387fe
CC Mode 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 ;; 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
|
581 ;; 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
|
582 |
7a3ac6c387fe
CC Mode 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 (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
|
584 (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
|
585 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
|
586 (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
|
587 (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
|
588 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
|
589 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
|
590 pos ; Current position. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
591 boundary-pos ; Position of last stmt boundary character (e.g. ;). |
44728
7a3ac6c387fe
CC Mode 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 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
|
593 last-label-pos ; Value of tok after last found colon. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
594 sym ; Symbol just scanned back over (e.g. 'while or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
595 ; 'boundary). See above |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
596 state ; Current state in the automaton. See above. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
597 saved-pos ; Current saved positions. See above |
44728
7a3ac6c387fe
CC Mode 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 stack ; Stack of conses (state . saved-pos). |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
599 (cond-key (or c-opt-block-stmt-key ; regexp which matches "for", "if", etc. |
44728
7a3ac6c387fe
CC Mode 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 "\\<\\>")) ; Matches nothing. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
601 (ret 'same) ; Return value. |
44728
7a3ac6c387fe
CC Mode 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 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
|
603 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
|
604 |
7a3ac6c387fe
CC Mode 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 (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
|
606 (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
|
607 |
7a3ac6c387fe
CC Mode 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 (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
|
609 (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
|
610 (/= (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
|
611 (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
|
612 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
613 ;; Try to skip back over unary operator characters, to register |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
614 ;; 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
|
615 (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
|
616 (setq pos (point)) |
51829
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
617 (if (c-mode-is-new-awk-p) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
618 (c-awk-backward-syntactic-ws) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
619 (c-backward-syntactic-ws)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
620 (/= (skip-chars-backward "-+!*&~@`#") 0))) ; ACM, 2002/5/31; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
621 ; Make a variable in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
622 ; cc-langs.el, maybe |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
623 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
624 ;; Skip back over any semicolon here. If it was a bare semicolon, we're |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
625 ;; done. Later on we ignore the boundaries for statements that doesn't |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
626 ;; contain any sexp. The only thing that is affected is that the error |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
627 ;; checking is a little less strict, and we really don't bother. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
628 (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
|
629 (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
|
630 (setq saved (point)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
631 (if (c-mode-is-new-awk-p) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
632 (c-awk-backward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
633 (c-backward-syntactic-ws)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
634 (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
|
635 (memq (char-before) '(?: nil)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
636 (eq (char-syntax (char-before)) ?\() |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
637 (and (c-mode-is-new-awk-p) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
638 (c-awk-after-logical-semicolon))))) ; ACM 2002/6/22 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
639 ;; ACM, 2002/7/20: What about giving a limit to the above function? |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
640 ;; ACM, 2003/6/16: The above two lines (checking for |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
641 ;; awk-logical-semicolon) are probably redundant after rewriting |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
642 ;; c-awk-backward-syntactic-ws. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
643 (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
|
644 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
|
645 |
7a3ac6c387fe
CC Mode 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 ;; 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
|
647 ;; 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
|
648 (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
|
649 (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
|
650 ;; 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
|
651 (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
|
652 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
653 ;; The following while loop goes back one sexp (balanced parens, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
654 ;; etc. with contents, or symbol or suchlike) each iteration. This |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
655 ;; movement is accomplished with a call to scan-sexps approx 130 lines |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
656 ;; below. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
657 (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
|
658 (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
|
659 (cond |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
660 ;; Check for macro start. Take this out for AWK Mode (ACM, 2002/5/31) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
661 ;; NO!! just make sure macro-start is nil in AWK Mode (ACM, 2002/6/22) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
662 ;; It always is (ACM, 2002/6/23) |
44728
7a3ac6c387fe
CC Mode 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 ((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
|
664 (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
|
665 (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
|
666 (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
|
667 (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
|
668 (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
|
669 (not (eq (char-before (1- (point))) ?\\))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
670 (looking-at c-opt-cpp-start) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
671 (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
|
672 (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
|
673 (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
|
674 (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
|
675 (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
|
676 (< (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
|
677 ;; 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
|
678 (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
|
679 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
|
680 (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
|
681 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
|
682 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
|
683 (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
|
684 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
685 ;; Do a round through the automaton if we've just passed a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
686 ;; statement boundary or passed a "while"-like token. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
687 ((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
|
688 (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
|
689 (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
|
690 |
7a3ac6c387fe
CC Mode 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 (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
|
692 (throw 'loop nil)) |
18720 | 693 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
694 ;; The PDA state handling. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
695 ;; |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
696 ;; Refer to the description of the PDA in the opening |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
697 ;; comments. In the following OR form, the first leaf |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
698 ;; attempts to handles one of the specific actions detailed |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
699 ;; (e.g., finding token "if" whilst in state `else-boundary'). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
700 ;; We drop through to the second leaf (which handles common |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
701 ;; state) if no specific handler is found in the first cond. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
702 ;; If a parsing error is detected (e.g. an "else" with no |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
703 ;; preceding "if"), we throw to the enclosing catch. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
704 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
705 ;; Note that the (eq state 'else) means |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
706 ;; "we've just passed an else", NOT "we're looking for an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
707 ;; else". |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
708 (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
|
709 ((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
|
710 (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
|
711 (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
|
712 (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
|
713 (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
|
714 |
7a3ac6c387fe
CC Mode 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 ((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
|
716 (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
|
717 (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
|
718 ((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
|
719 (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
|
720 (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
|
721 |
7a3ac6c387fe
CC Mode 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 ((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
|
723 (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
|
724 ;; 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
|
725 ;; 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
|
726 ;; 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
|
727 ;; 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
|
728 (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
|
729 (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
|
730 (setq state 'while-boundary)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
731 (c-bos-pop-state-and-retry))) ; Can't be a do-while |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
732 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
733 ((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
|
734 (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
|
735 (c-bos-pop-state (setq ret 'beginning))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
736 ((eq sym 'boundary) ; isn't a do-while |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
737 (c-bos-restore-pos) ; the position of the while |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
738 (c-bos-pop-state)))) ; no longer searching for do. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
739 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
740 ((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
|
741 (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
|
742 (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
|
743 (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
|
744 (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
|
745 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
746 ((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
|
747 (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
|
748 ((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
|
749 (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
|
750 ((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
|
751 (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
|
752 ((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
|
753 (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
|
754 (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
|
755 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
756 ;; This is state common. We get here when the previous |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
757 ;; cond statement found no particular state handler. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
758 (cond ((eq sym 'boundary) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
759 ;; If we have a boundary at the start |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
760 ;; position we push a frame to go to the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
761 ;; previous statement. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
762 (if (>= pos start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
763 (c-bos-push-state) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
764 (c-bos-pop-state))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
765 ((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
|
766 (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
|
767 (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
|
768 (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
|
769 ((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
|
770 (when (or (not pptok) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
771 (memq (char-after pptok) delims) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
772 (and (c-mode-is-new-awk-p) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
773 (or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
774 ;; might we be calling this from |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
775 ;; c-awk-after-if-do-for-while-condition-p? |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
776 ;; If so, avoid infinite recursion. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
777 (and (eq (point) start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
778 (c-awk-NL-prop-not-set)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
779 ;; The following may recursively |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
780 ;; call this function. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
781 (c-awk-completed-stmt-ws-ends-line-p pptok)))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
782 ;; 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
|
783 ;; 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
|
784 ;; 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
|
785 ;; can't be a do-while. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
786 ;; ACM, 2002/5/31; IT CAN IN AWK 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
|
787 (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
|
788 (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
|
789 ((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
|
790 (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
|
791 (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
|
792 (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
|
793 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
794 (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
|
795 ;; 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
|
796 ;; 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
|
797 ;; 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
|
798 (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
|
799 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
|
800 c-maybe-labelp nil)))) |
18720 | 801 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
802 ;; Step to the previous sexp, but not if we crossed a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
803 ;; boundary, since that doesn't consume an sexp. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
804 (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
|
805 (setq ret 'previous) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
806 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
807 ;; HERE IS THE SINGLE PLACE INSIDE THE PDA LOOP WHERE WE MOVE |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
808 ;; BACKWARDS THROUGH THE SOURCE. The following loop goes back |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
809 ;; one sexp and then only loops in special circumstances (line |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
810 ;; continuations and skipping past entire macros). |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
811 (while |
19377
989d0412ada3
(c-end-of-statement-1): Eliminate false hits on important characters
Richard M. Stallman <rms@gnu.org>
parents:
19301
diff
changeset
|
812 (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
|
813 (or (c-safe (goto-char (scan-sexps (point) -1)) t) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
814 ;; Give up if we hit an unbalanced block. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
815 ;; Since the stack won't be empty the code |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
816 ;; below will report a suitable error. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
817 (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
|
818 (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
|
819 ;; 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
|
820 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
|
821 (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
|
822 ;; 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
|
823 ;; 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
|
824 nil) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
825 ((not (c-mode-is-new-awk-p)) ; Changed from t, ACM 2002/6/25 |
44728
7a3ac6c387fe
CC Mode 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 ;; 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
|
827 ;; 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
|
828 (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
|
829 (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
|
830 (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
|
831 (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
|
832 (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
|
833 (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
|
834 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
|
835 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
836 ;; Did the last movement by a sexp cross a statement boundary? |
44728
7a3ac6c387fe
CC Mode 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 (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
|
838 (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
|
839 (c-looking-at-inexpr-block lim nil) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
840 (looking-at "\\s\(")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
841 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
842 ;; Should not include the paren sexp we've |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
843 ;; passed over in the boundary check. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
844 (if (> (point) (- pos 100)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
845 (c-forward-sexp 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
846 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
847 ;; Find its end position this way instead of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
848 ;; moving forward if the sexp is large. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
849 (goto-char pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
850 (while |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
851 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
852 (goto-char (1+ (c-down-list-backward))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
853 (unless macro-start |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
854 ;; Check that we didn't step into |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
855 ;; a macro from the end. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
856 (let ((macro-start |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
857 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
858 (and (c-beginning-of-macro) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
859 (point))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
860 (when macro-start |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
861 (goto-char macro-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
862 t))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
863 |
44728
7a3ac6c387fe
CC Mode 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 (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
|
865 (point) pos))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
866 |
44728
7a3ac6c387fe
CC Mode 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 (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
|
868 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
|
869 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
|
870 sym 'boundary) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
871 (throw 'loop t))) ; like a C "continue". Analyze the next 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
|
872 |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
873 (when (and (numberp c-maybe-labelp) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
874 (not ignore-labels) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
875 (not (looking-at "\\s\("))) |
44728
7a3ac6c387fe
CC Mode 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 ;; 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
|
877 ;; 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
|
878 (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
|
879 (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
|
880 (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
|
881 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
|
882 |
7a3ac6c387fe
CC Mode 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 ;; 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
|
884 (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
|
885 (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
|
886 (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
|
887 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
|
888 (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
|
889 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
890 ;; We've moved back by a sexp, so update the token positions. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
891 (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
|
892 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
|
893 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
|
894 tok (point) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
895 pos tok))) ; Not nil (for the while loop). |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
896 |
7a3ac6c387fe
CC Mode 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 ;; 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
|
898 (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
|
899 (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
|
900 (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
|
901 (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
|
902 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
|
903 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
904 (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
|
905 (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
|
906 ;; 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
|
907 ;; 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
|
908 (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
|
909 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
|
910 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
|
911 (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
|
912 ((= 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
|
913 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
914 (when (and c-maybe-labelp |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
915 (not ignore-labels) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
916 (not (eq ret 'beginning)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
917 after-labels-pos) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
918 ;; 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
|
919 ;; 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
|
920 (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
|
921 (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
|
922 (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
|
923 (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
|
924 (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
|
925 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
926 ;; 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
|
927 (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
|
928 (while (progn |
51829
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
929 (if (c-mode-is-new-awk-p) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
930 (c-awk-backward-syntactic-ws) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
931 (c-backward-syntactic-ws)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
932 (/= (skip-chars-backward "-+!*&~@`#") 0)) ; Hopefully the # won't hurt awk. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
933 (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
|
934 (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
|
935 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
|
936 |
7a3ac6c387fe
CC Mode 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 (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
|
938 "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
|
939 statement or declaration boundaries. The returned value is actually |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
940 the position of the earliest boundary char. FROM must not be within |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
941 a string or comment. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
942 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
943 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
|
944 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
|
945 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
|
946 (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
|
947 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
|
948 (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
|
949 (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
|
950 (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
|
951 (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
|
952 (< (point) to)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
953 (if (setq lit-range (c-literal-limits from)) ; Have we landed in a string/comment? |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
954 (progn (goto-char (setq from (cdr lit-range))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
955 (if (and (c-mode-is-new-awk-p) (bolp)) ; ACM 2002/7/17. Make sure we |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
956 (backward-char))) ; don't skip over a virtual semi-colon after an awk comment. :-( |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
957 (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
|
958 (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
|
959 (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
|
960 (< (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
|
961 ;; 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
|
962 (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
|
963 (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
|
964 ((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
|
965 ;; 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
|
966 ;; 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
|
967 (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
|
968 skip-chars (substring c-stmt-delim-chars 0 -2))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
969 ((and (eolp) ; Can only happen in AWK Mode |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
970 (not (c-awk-completed-stmt-ws-ends-line-p))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
971 (forward-char)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
972 ((and (c-mode-is-new-awk-p) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
973 (bolp) lit-range ; awk: comment/string ended prev line. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
974 (not (c-awk-completed-stmt-ws-ends-prev-line-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
|
975 (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
|
976 nil)))) |
18720 | 977 |
978 | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
979 ;; A set of functions that covers various idiosyncrasies in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
980 ;; implementations of `forward-comment'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
981 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
982 ;; Note: Some emacsen considers incorrectly that any line comment |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
983 ;; ending with a backslash continues to the next line. I can't think |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
984 ;; of any way to work around that in a reliable way without changing |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
985 ;; the buffer, though. Suggestions welcome. ;) (No, temporarily |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
986 ;; changing the syntax for backslash doesn't work since we must treat |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
987 ;; escapes in string literals correctly.) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
988 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
989 (defun c-forward-single-comment () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
990 "Move forward past whitespace and the closest following comment, if any. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
991 Return t if a comment was found, nil otherwise. In either case, the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
992 point is moved past the following whitespace. Line continuations, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
993 i.e. a backslashes followed by line breaks, are treated as whitespace. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
994 The line breaks that end line comments are considered to be the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
995 comment enders, so the point will be put on the beginning of the next |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
996 line if it moved past a line comment. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
997 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
998 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
999 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1000 (let ((start (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1001 (when (looking-at "\\([ \t\n\r\f\v]\\|\\\\[\n\r]\\)+") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1002 (goto-char (match-end 0))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1003 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1004 (when (forward-comment 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1005 (if (eobp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1006 ;; Some emacsen (e.g. XEmacs 21) return t when moving |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1007 ;; forwards at eob. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1008 nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1009 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1010 ;; Emacs includes the ending newline in a b-style (c++) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1011 ;; comment, but XEmacs doesn't. We depend on the Emacs |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1012 ;; behavior (which also is symmetric). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1013 (if (and (eolp) (elt (parse-partial-sexp start (point)) 7)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1014 (condition-case nil (forward-char 1))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1015 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1016 t)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1017 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1018 (defsubst c-forward-comments () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1019 "Move forward past all following whitespace and comments. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1020 Line continuations, i.e. a backslashes followed by line breaks, are |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1021 treated as whitespace. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1022 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1023 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1024 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1025 (while (or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1026 ;; If forward-comment in at least XEmacs 21 is given a large |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1027 ;; positive value, it'll loop all the way through if it hits |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1028 ;; eob. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1029 (and (forward-comment 5) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1030 ;; Some emacsen (e.g. XEmacs 21) return t when moving |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1031 ;; forwards at eob. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1032 (not (eobp))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1033 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1034 (when (looking-at "\\\\[\n\r]") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1035 (forward-char 2) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1036 t)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1037 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1038 (defun c-backward-single-comment () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1039 "Move backward past whitespace and the closest preceding comment, if any. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1040 Return t if a comment was found, nil otherwise. In either case, the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1041 point is moved past the preceding whitespace. Line continuations, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1042 i.e. a backslashes followed by line breaks, are treated as whitespace. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1043 The line breaks that end line comments are considered to be the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1044 comment enders, so the point cannot be at the end of the same line to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1045 move over a line comment. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1046 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1047 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1048 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1049 (let ((start (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1050 ;; When we got newline terminated comments, forward-comment in all |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1051 ;; supported emacsen so far will stop at eol of each line not |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1052 ;; ending with a comment when moving backwards. This corrects for |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1053 ;; that, and at the same time handles line continuations. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1054 (while (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1055 (skip-chars-backward " \t\n\r\f\v") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1056 (and (looking-at "[\n\r]") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1057 (eq (char-before) ?\\) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1058 (< (point) start))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1059 (backward-char)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1060 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1061 (if (bobp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1062 ;; Some emacsen (e.g. Emacs 19.34) return t when moving |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1063 ;; backwards at bob. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1064 nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1065 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1066 ;; Leave point after the closest following newline if we've |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1067 ;; backed up over any above, since forward-comment won't move |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1068 ;; backward over a line comment if point is at the end of the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1069 ;; same line. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1070 (re-search-forward "\\=\\s *[\n\r]" start t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1071 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1072 (if (if (forward-comment -1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1073 (if (eolp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1074 ;; If forward-comment above succeeded and we're at eol |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1075 ;; then the newline we moved over above didn't end a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1076 ;; line comment, so we give it another go. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1077 (forward-comment -1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1078 t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1079 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1080 ;; Emacs <= 20 and XEmacs move back over the closer of a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1081 ;; block comment that lacks an opener. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1082 (if (looking-at "\\*/") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1083 (progn (forward-char 2) nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1084 t))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1085 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1086 (defsubst c-backward-comments () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1087 "Move backward past all preceding whitespace and comments. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1088 Line continuations, i.e. a backslashes followed by line breaks, are |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1089 treated as whitespace. The line breaks that end line comments are |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1090 considered to be the comment enders, so the point cannot be at the end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1091 of the same line to move over a line comment. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1092 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1093 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1094 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1095 (let ((start (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1096 (while (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1097 ;; `forward-comment' in some emacsen (e.g. Emacs 19.34) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1098 ;; return t when moving backwards at bob. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1099 (not (bobp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1100 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1101 (if (forward-comment -1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1102 (if (looking-at "\\*/") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1103 ;; Emacs <= 20 and XEmacs move back over the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1104 ;; closer of a block comment that lacks an opener. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1105 (progn (forward-char 2) nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1106 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1107 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1108 ;; XEmacs treats line continuations as whitespace but |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1109 ;; only in the backward direction, which seems a bit |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1110 ;; odd. Anyway, this is necessary for Emacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1111 (when (and (looking-at "[\n\r]") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1112 (eq (char-before) ?\\) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1113 (< (point) start)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1114 (backward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1115 t)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1116 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1117 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1118 ;; Tools for skipping over syntactic whitespace. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1119 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1120 ;; The following functions use text properties to cache searches over |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1121 ;; large regions of syntactic whitespace. It works as follows: |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1122 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1123 ;; o If a syntactic whitespace region contains anything but simple |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1124 ;; whitespace (i.e. space, tab and line breaks), the text property |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1125 ;; `c-in-sws' is put over it. At places where we have stopped |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1126 ;; within that region there's also a `c-is-sws' text property. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1127 ;; That since there typically are nested whitespace inside that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1128 ;; must be handled separately, e.g. whitespace inside a comment or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1129 ;; cpp directive. Thus, from one point with `c-is-sws' it's safe |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1130 ;; to jump to another point with that property within the same |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1131 ;; `c-in-sws' region. It can be likened to a ladder where |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1132 ;; `c-in-sws' marks the bars and `c-is-sws' the rungs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1133 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1134 ;; o The `c-is-sws' property is put on the simple whitespace chars at |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1135 ;; a "rung position" and also maybe on the first following char. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1136 ;; As many characters as can be conveniently found in this range |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1137 ;; are marked, but no assumption can be made that the whole range |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1138 ;; is marked (it could be clobbered by later changes, for |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1139 ;; instance). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1140 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1141 ;; Note that some part of the beginning of a sequence of simple |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1142 ;; whitespace might be part of the end of a preceding line comment |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1143 ;; or cpp directive and must not be considered part of the "rung". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1144 ;; Such whitespace is some amount of horizontal whitespace followed |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1145 ;; by a newline. In the case of cpp directives it could also be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1146 ;; two newlines with horizontal whitespace between them. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1147 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1148 ;; The reason to include the first following char is to cope with |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1149 ;; "rung positions" that doesn't have any ordinary whitespace. If |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1150 ;; `c-is-sws' is put on a token character it does not have |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1151 ;; `c-in-sws' set simultaneously. That's the only case when that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1152 ;; can occur, and the reason for not extending the `c-in-sws' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1153 ;; region to cover it is that the `c-in-sws' region could then be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1154 ;; accidentally merged with a following one if the token is only |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1155 ;; one character long. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1156 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1157 ;; o On buffer changes the `c-in-sws' and `c-is-sws' properties are |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1158 ;; removed in the changed region. If the change was inside |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1159 ;; syntactic whitespace that means that the "ladder" is broken, but |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1160 ;; a later call to `c-forward-sws' or `c-backward-sws' will use the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1161 ;; parts on either side and use an ordinary search only to "repair" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1162 ;; the gap. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1163 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1164 ;; Special care needs to be taken if a region is removed: If there |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1165 ;; are `c-in-sws' on both sides of it which do not connect inside |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1166 ;; the region then they can't be joined. If e.g. a marked macro is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1167 ;; broken, syntactic whitespace inside the new text might be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1168 ;; marked. If those marks would become connected with the old |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1169 ;; `c-in-sws' range around the macro then we could get a ladder |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1170 ;; with one end outside the macro and the other at some whitespace |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1171 ;; within it. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1172 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1173 ;; The main motivation for this system is to increase the speed in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1174 ;; skipping over the large whitespace regions that can occur at the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1175 ;; top level in e.g. header files that contain a lot of comments and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1176 ;; cpp directives. For small comments inside code it's probably |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1177 ;; slower than using `forward-comment' straightforwardly, but speed is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1178 ;; not a significant factor there anyway. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1179 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1180 ; (defface c-debug-is-sws-face |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1181 ; '((t (:background "GreenYellow"))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1182 ; "Debug face to mark the `c-is-sws' property.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1183 ; (defface c-debug-in-sws-face |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1184 ; '((t (:underline t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1185 ; "Debug face to mark the `c-in-sws' property.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1186 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1187 ; (defun c-debug-put-sws-faces () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1188 ; ;; Put the sws debug faces on all the `c-is-sws' and `c-in-sws' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1189 ; ;; properties in the buffer. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1190 ; (interactive) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1191 ; (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1192 ; (let (in-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1193 ; (goto-char (point-min)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1194 ; (setq in-face (if (get-text-property (point) 'c-is-sws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1195 ; (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1196 ; (while (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1197 ; (goto-char (next-single-property-change |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1198 ; (point) 'c-is-sws nil (point-max))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1199 ; (if in-face |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1200 ; (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1201 ; (c-debug-add-face in-face (point) 'c-debug-is-sws-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1202 ; (setq in-face nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1203 ; (setq in-face (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1204 ; (not (eobp)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1205 ; (goto-char (point-min)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1206 ; (setq in-face (if (get-text-property (point) 'c-in-sws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1207 ; (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1208 ; (while (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1209 ; (goto-char (next-single-property-change |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1210 ; (point) 'c-in-sws nil (point-max))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1211 ; (if in-face |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1212 ; (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1213 ; (c-debug-add-face in-face (point) 'c-debug-in-sws-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1214 ; (setq in-face nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1215 ; (setq in-face (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1216 ; (not (eobp))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1217 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1218 (defmacro c-debug-sws-msg (&rest args) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1219 ;;`(message ,@args) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1220 ) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1221 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1222 (defmacro c-put-is-sws (beg end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1223 `(let ((beg ,beg) (end ,end)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1224 (put-text-property beg end 'c-is-sws t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1225 ,@(when (facep 'c-debug-is-sws-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1226 `((c-debug-add-face beg end 'c-debug-is-sws-face))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1227 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1228 (defmacro c-put-in-sws (beg end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1229 `(let ((beg ,beg) (end ,end)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1230 (put-text-property beg end 'c-in-sws t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1231 ,@(when (facep 'c-debug-is-sws-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1232 `((c-debug-add-face beg end 'c-debug-in-sws-face))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1233 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1234 (defmacro c-remove-is-sws (beg end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1235 `(let ((beg ,beg) (end ,end)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1236 (remove-text-properties beg end '(c-is-sws nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1237 ,@(when (facep 'c-debug-is-sws-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1238 `((c-debug-remove-face beg end 'c-debug-is-sws-face))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1239 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1240 (defmacro c-remove-in-sws (beg end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1241 `(let ((beg ,beg) (end ,end)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1242 (remove-text-properties beg end '(c-in-sws nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1243 ,@(when (facep 'c-debug-is-sws-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1244 `((c-debug-remove-face beg end 'c-debug-in-sws-face))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1245 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1246 (defmacro c-remove-is-and-in-sws (beg end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1247 `(let ((beg ,beg) (end ,end)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1248 (remove-text-properties beg end '(c-is-sws nil c-in-sws nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1249 ,@(when (facep 'c-debug-is-sws-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1250 `((c-debug-remove-face beg end 'c-debug-is-sws-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1251 (c-debug-remove-face beg end 'c-debug-in-sws-face))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1252 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1253 (defsubst c-invalidate-sws-region-after (beg end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1254 ;; Called from `after-change-functions'. Note that if |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1255 ;; `c-forward-sws' or `c-backward-sws' are used outside |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1256 ;; `c-save-buffer-state' or similar then this will remove the cache |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1257 ;; properties right after they're added. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1258 |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
1259 (save-excursion |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1260 ;; Adjust the end to remove the properties in any following simple |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1261 ;; ws up to and including the next line break, if there is any |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1262 ;; after the changed region. This is necessary e.g. when a rung |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1263 ;; marked empty line is converted to a line comment by inserting |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1264 ;; "//" before the line break. In that case the line break would |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1265 ;; keep the rung mark which could make a later `c-backward-sws' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1266 ;; move into the line comment instead of over it. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1267 (goto-char end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1268 (skip-chars-forward " \t\f\v") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1269 (when (and (eolp) (not (eobp))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1270 (setq end (1+ (point))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1271 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1272 (when (and (= beg end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1273 (get-text-property beg 'c-in-sws) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
1274 (> beg (point-min)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1275 (get-text-property (1- beg) 'c-in-sws)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1276 ;; Ensure that an `c-in-sws' range gets broken. Note that it isn't |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1277 ;; safe to keep a range that was continuous before the change. E.g: |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1278 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1279 ;; #define foo |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1280 ;; \ |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1281 ;; bar |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1282 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1283 ;; There can be a "ladder" between "#" and "b". Now, if the newline |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1284 ;; after "foo" is removed then "bar" will become part of the cpp |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1285 ;; directive instead of a syntactically relevant token. In that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1286 ;; case there's no longer syntactic ws from "#" to "b". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1287 (setq beg (1- beg))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1288 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1289 (c-debug-sws-msg "c-invalidate-sws-region-after [%s..%s]" beg end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1290 (c-remove-is-and-in-sws beg end)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1291 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1292 (defun c-forward-sws () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1293 ;; Used by `c-forward-syntactic-ws' to implement the unbounded search. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1294 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1295 (let (;; `rung-pos' is set to a position as early as possible in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1296 ;; unmarked part of the simple ws region. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1297 (rung-pos (point)) next-rung-pos rung-end-pos last-put-in-sws-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1298 rung-is-marked next-rung-is-marked simple-ws-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1299 ;; `safe-start' is set when it's safe to cache the start position. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1300 ;; It's not set if we've initially skipped over comments and line |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1301 ;; continuations since we might have gone out through the end of a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1302 ;; macro then. This provision makes `c-forward-sws' not populate the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1303 ;; cache in the majority of cases, but otoh is `c-backward-sws' by far |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1304 ;; more common. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1305 safe-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1306 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1307 ;; Skip simple ws and do a quick check on the following character to see |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1308 ;; if it's anything that can't start syntactic ws, so we can bail out |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1309 ;; early in the majority of cases when there just are a few ws chars. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1310 (skip-chars-forward " \t\n\r\f\v") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1311 (when (looking-at c-syntactic-ws-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1312 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1313 (setq rung-end-pos (min (1+ (point)) (point-max))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1314 (if (setq rung-is-marked (text-property-any rung-pos rung-end-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1315 'c-is-sws t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1316 ;; Find the last rung position to avoid setting properties in all |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1317 ;; the cases when the marked rung is complete. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1318 ;; (`next-single-property-change' is certain to move at least one |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1319 ;; step forward.) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1320 (setq rung-pos (1- (next-single-property-change |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1321 rung-is-marked 'c-is-sws nil rung-end-pos))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1322 ;; Got no marked rung here. Since the simple ws might have started |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1323 ;; inside a line comment or cpp directive we must set `rung-pos' as |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1324 ;; high as possible. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1325 (setq rung-pos (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1326 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1327 (while |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1328 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1329 (while |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1330 (when (and rung-is-marked |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1331 (get-text-property (point) 'c-in-sws)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1332 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1333 ;; The following search is the main reason that `c-in-sws' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1334 ;; and `c-is-sws' aren't combined to one property. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1335 (goto-char (next-single-property-change |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1336 (point) 'c-in-sws nil (point-max))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1337 (unless (get-text-property (point) 'c-is-sws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1338 ;; If the `c-in-sws' region extended past the last |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1339 ;; `c-is-sws' char we have to go back a bit. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1340 (or (get-text-property (1- (point)) 'c-is-sws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1341 (goto-char (previous-single-property-change |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1342 (point) 'c-is-sws))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1343 (backward-char)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1344 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1345 (c-debug-sws-msg |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1346 "c-forward-sws cached move %s -> %s (max %s)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1347 rung-pos (point) (point-max)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1348 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1349 (setq rung-pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1350 (and (> (skip-chars-forward " \t\n\r\f\v") 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1351 (not (eobp)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1352 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1353 ;; We'll loop here if there is simple ws after the last rung. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1354 ;; That means that there's been some change in it and it's |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1355 ;; possible that we've stepped into another ladder, so extend |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1356 ;; the previous one to join with it if there is one, and try to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1357 ;; use the cache again. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1358 (c-debug-sws-msg |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1359 "c-forward-sws extending rung with [%s..%s] (max %s)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1360 (1+ rung-pos) (1+ (point)) (point-max)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1361 (unless (get-text-property (point) 'c-is-sws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1362 ;; Remove any `c-in-sws' property from the last char of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1363 ;; the rung before we mark it with `c-is-sws', so that we |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1364 ;; won't connect with the remains of a broken "ladder". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1365 (c-remove-in-sws (point) (1+ (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1366 (c-put-is-sws (1+ rung-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1367 (1+ (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1368 (c-put-in-sws rung-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1369 (setq rung-pos (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1370 last-put-in-sws-pos rung-pos))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1371 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1372 (setq simple-ws-end (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1373 (c-forward-comments) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1374 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1375 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1376 ((/= (point) simple-ws-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1377 ;; Skipped over comments. Don't cache at eob in case the buffer |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1378 ;; is narrowed. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1379 (not (eobp))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1380 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1381 ((save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1382 (and c-opt-cpp-prefix |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1383 (looking-at c-opt-cpp-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1384 (progn (skip-chars-backward " \t") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1385 (bolp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1386 (or (bobp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1387 (progn (backward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1388 (not (eq (char-before) ?\\)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1389 ;; Skip a preprocessor directive. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1390 (end-of-line) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1391 (while (and (eq (char-before) ?\\) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1392 (= (forward-line 1) 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1393 (end-of-line)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1394 (forward-line 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1395 (setq safe-start t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1396 ;; Don't cache at eob in case the buffer is narrowed. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1397 (not (eobp))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1398 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1399 ;; We've searched over a piece of non-white syntactic ws. See if this |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1400 ;; can be cached. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1401 (setq next-rung-pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1402 (skip-chars-forward " \t\n\r\f\v") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1403 (setq rung-end-pos (min (1+ (point)) (point-max))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1404 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1405 (if (or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1406 ;; Cache if we haven't skipped comments only, and if we started |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1407 ;; either from a marked rung or from a completely uncached |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1408 ;; position. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1409 (and safe-start |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1410 (or rung-is-marked |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1411 (not (get-text-property simple-ws-end 'c-in-sws)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1412 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1413 ;; See if there's a marked rung in the encountered simple ws. If |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1414 ;; so then we can cache, unless `safe-start' is nil. Even then |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1415 ;; we need to do this to check if the cache can be used for the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1416 ;; next step. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1417 (and (setq next-rung-is-marked |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1418 (text-property-any next-rung-pos rung-end-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1419 'c-is-sws t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1420 safe-start)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1421 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1422 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1423 (c-debug-sws-msg |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1424 "c-forward-sws caching [%s..%s] - [%s..%s] (max %s)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1425 rung-pos (1+ simple-ws-end) next-rung-pos rung-end-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1426 (point-max)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1427 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1428 ;; Remove the properties for any nested ws that might be cached. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1429 ;; Only necessary for `c-is-sws' since `c-in-sws' will be set |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1430 ;; anyway. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1431 (c-remove-is-sws (1+ simple-ws-end) next-rung-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1432 (unless (and rung-is-marked (= rung-pos simple-ws-end)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1433 (c-put-is-sws rung-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1434 (1+ simple-ws-end)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1435 (setq rung-is-marked t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1436 (c-put-in-sws rung-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1437 (setq rung-pos (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1438 last-put-in-sws-pos rung-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1439 (unless (get-text-property (1- rung-end-pos) 'c-is-sws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1440 ;; Remove any `c-in-sws' property from the last char of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1441 ;; the rung before we mark it with `c-is-sws', so that we |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1442 ;; won't connect with the remains of a broken "ladder". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1443 (c-remove-in-sws (1- rung-end-pos) rung-end-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1444 (c-put-is-sws next-rung-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1445 rung-end-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1446 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1447 (c-debug-sws-msg |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1448 "c-forward-sws not caching [%s..%s] - [%s..%s] (max %s)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1449 rung-pos (1+ simple-ws-end) next-rung-pos rung-end-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1450 (point-max)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1451 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1452 ;; Set `rung-pos' for the next rung. It's the same thing here as |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1453 ;; initially, except that the rung position is set as early as |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1454 ;; possible since we can't be in the ending ws of a line comment or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1455 ;; cpp directive now. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1456 (if (setq rung-is-marked next-rung-is-marked) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1457 (setq rung-pos (1- (next-single-property-change |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1458 rung-is-marked 'c-is-sws nil rung-end-pos))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1459 (setq rung-pos next-rung-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1460 (setq safe-start t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1461 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1462 ;; Make sure that the newly marked `c-in-sws' region doesn't connect to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1463 ;; another one after the point (which might occur when editing inside a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1464 ;; comment or macro). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1465 (when (eq last-put-in-sws-pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1466 (cond ((< last-put-in-sws-pos (point-max)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1467 (c-debug-sws-msg |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1468 "c-forward-sws clearing at %s for cache separation" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1469 last-put-in-sws-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1470 (c-remove-in-sws last-put-in-sws-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1471 (1+ last-put-in-sws-pos))) |
24282 | 1472 (t |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1473 ;; If at eob we have to clear the last character before the end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1474 ;; instead since the buffer might be narrowed and there might |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1475 ;; be a `c-in-sws' after (point-max). In this case it's |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1476 ;; necessary to clear both properties. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1477 (c-debug-sws-msg |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1478 "c-forward-sws clearing thoroughly at %s for cache separation" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1479 (1- last-put-in-sws-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1480 (c-remove-is-and-in-sws (1- last-put-in-sws-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1481 last-put-in-sws-pos)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1482 ))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1483 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1484 (defun c-backward-sws () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1485 ;; Used by `c-backward-syntactic-ws' to implement the unbounded search. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1486 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1487 (let (;; `rung-pos' is set to a position as late as possible in the unmarked |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1488 ;; part of the simple ws region. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1489 (rung-pos (point)) next-rung-pos last-put-in-sws-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1490 rung-is-marked simple-ws-beg cmt-skip-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1491 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1492 ;; Skip simple horizontal ws and do a quick check on the preceding |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1493 ;; character to see if it's anying that can't end syntactic ws, so we can |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1494 ;; bail out early in the majority of cases when there just are a few ws |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1495 ;; chars. Newlines are complicated in the backward direction, so we can't |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1496 ;; skip over them. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1497 (skip-chars-backward " \t\f") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1498 (when (and (not (bobp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1499 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1500 (backward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1501 (looking-at c-syntactic-ws-end))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1502 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1503 ;; Try to find a rung position in the simple ws preceding point, so that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1504 ;; we can get a cache hit even if the last bit of the simple ws has |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1505 ;; changed recently. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1506 (setq simple-ws-beg (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1507 (skip-chars-backward " \t\n\r\f\v") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1508 (if (setq rung-is-marked (text-property-any |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1509 (point) (min (1+ rung-pos) (point-max)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1510 'c-is-sws t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1511 ;; `rung-pos' will be the earliest marked position, which means that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1512 ;; there might be later unmarked parts in the simple ws region. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1513 ;; It's not worth the effort to fix that; the last part of the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1514 ;; simple ws is also typically edited often, so it could be wasted. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1515 (goto-char (setq rung-pos rung-is-marked)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1516 (goto-char simple-ws-beg)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1517 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1518 (while |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1519 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1520 (while |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1521 (when (and rung-is-marked |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1522 (not (bobp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1523 (get-text-property (1- (point)) 'c-in-sws)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1524 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1525 ;; The following search is the main reason that `c-in-sws' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1526 ;; and `c-is-sws' aren't combined to one property. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1527 (goto-char (previous-single-property-change |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1528 (point) 'c-in-sws nil (point-min))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1529 (unless (get-text-property (point) 'c-is-sws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1530 ;; If the `c-in-sws' region extended past the first |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1531 ;; `c-is-sws' char we have to go forward a bit. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1532 (goto-char (next-single-property-change |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1533 (point) 'c-is-sws))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1534 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1535 (c-debug-sws-msg |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1536 "c-backward-sws cached move %s <- %s (min %s)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1537 (point) rung-pos (point-min)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1538 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1539 (setq rung-pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1540 (if (and (< (min (skip-chars-backward " \t\f\v") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1541 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1542 (setq simple-ws-beg (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1543 (skip-chars-backward " \t\n\r\f\v"))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1544 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1545 (setq rung-is-marked |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1546 (text-property-any (point) rung-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1547 'c-is-sws t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1548 t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1549 (goto-char simple-ws-beg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1550 nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1551 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1552 ;; We'll loop here if there is simple ws before the first rung. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1553 ;; That means that there's been some change in it and it's |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1554 ;; possible that we've stepped into another ladder, so extend |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1555 ;; the previous one to join with it if there is one, and try to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1556 ;; use the cache again. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1557 (c-debug-sws-msg |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1558 "c-backward-sws extending rung with [%s..%s] (min %s)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1559 rung-is-marked rung-pos (point-min)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1560 (unless (get-text-property (1- rung-pos) 'c-is-sws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1561 ;; Remove any `c-in-sws' property from the last char of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1562 ;; the rung before we mark it with `c-is-sws', so that we |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1563 ;; won't connect with the remains of a broken "ladder". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1564 (c-remove-in-sws (1- rung-pos) rung-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1565 (c-put-is-sws rung-is-marked |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1566 rung-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1567 (c-put-in-sws rung-is-marked |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1568 (1- rung-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1569 (setq rung-pos rung-is-marked |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1570 last-put-in-sws-pos rung-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1571 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1572 (c-backward-comments) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1573 (setq cmt-skip-pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1574 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1575 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1576 ((and c-opt-cpp-prefix |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1577 (/= cmt-skip-pos simple-ws-beg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1578 (c-beginning-of-macro)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1579 ;; Inside a cpp directive. See if it should be skipped over. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1580 (let ((cpp-beg (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1581 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1582 ;; Move back over all line continuations in the region skipped |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1583 ;; over by `c-backward-comments'. If we go past it then we |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1584 ;; started inside the cpp directive. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1585 (goto-char simple-ws-beg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1586 (beginning-of-line) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1587 (while (and (> (point) cmt-skip-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1588 (progn (backward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1589 (eq (char-before) ?\\))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1590 (beginning-of-line)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1591 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1592 (if (< (point) cmt-skip-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1593 ;; Don't move past the cpp directive if we began inside |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1594 ;; it. Note that the position at the end of the last line |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1595 ;; of the macro is also considered to be within it. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1596 (progn (goto-char cmt-skip-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1597 nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1598 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1599 ;; It's worthwhile to spend a little bit of effort on finding |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1600 ;; the end of the macro, to get a good `simple-ws-beg' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1601 ;; position for the cache. Note that `c-backward-comments' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1602 ;; could have stepped over some comments before going into |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1603 ;; the macro, and then `simple-ws-beg' must be kept on the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1604 ;; same side of those comments. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1605 (goto-char simple-ws-beg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1606 (skip-chars-backward " \t\n\r\f\v") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1607 (if (eq (char-before) ?\\) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1608 (forward-char)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1609 (forward-line 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1610 (if (< (point) simple-ws-beg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1611 ;; Might happen if comments after the macro were skipped |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1612 ;; over. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1613 (setq simple-ws-beg (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1614 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1615 (goto-char cpp-beg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1616 t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1617 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1618 ((/= (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1619 (skip-chars-forward " \t\n\r\f\v" simple-ws-beg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1620 (setq next-rung-pos (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1621 simple-ws-beg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1622 ;; Skipped over comments. Must put point at the end of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1623 ;; the simple ws at point since we might be after a line |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1624 ;; comment or cpp directive that's been partially |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1625 ;; narrowed out, and we can't risk marking the simple ws |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1626 ;; at the end of it. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1627 (goto-char next-rung-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1628 t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1629 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1630 ;; We've searched over a piece of non-white syntactic ws. See if this |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1631 ;; can be cached. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1632 (setq next-rung-pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1633 (skip-chars-backward " \t\f\v") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1634 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1635 (if (or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1636 ;; Cache if we started either from a marked rung or from a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1637 ;; completely uncached position. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1638 rung-is-marked |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1639 (not (get-text-property (1- simple-ws-beg) 'c-in-sws)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1640 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1641 ;; Cache if there's a marked rung in the encountered simple ws. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1642 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1643 (skip-chars-backward " \t\n\r\f\v") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1644 (text-property-any (point) (min (1+ next-rung-pos) (point-max)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1645 'c-is-sws t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1646 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1647 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1648 (c-debug-sws-msg |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1649 "c-backward-sws caching [%s..%s] - [%s..%s] (min %s)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1650 (point) (1+ next-rung-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1651 simple-ws-beg (min (1+ rung-pos) (point-max)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1652 (point-min)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1653 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1654 ;; Remove the properties for any nested ws that might be cached. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1655 ;; Only necessary for `c-is-sws' since `c-in-sws' will be set |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1656 ;; anyway. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1657 (c-remove-is-sws (1+ next-rung-pos) simple-ws-beg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1658 (unless (and rung-is-marked (= simple-ws-beg rung-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1659 (let ((rung-end-pos (min (1+ rung-pos) (point-max)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1660 (unless (get-text-property (1- rung-end-pos) 'c-is-sws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1661 ;; Remove any `c-in-sws' property from the last char of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1662 ;; the rung before we mark it with `c-is-sws', so that we |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1663 ;; won't connect with the remains of a broken "ladder". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1664 (c-remove-in-sws (1- rung-end-pos) rung-end-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1665 (c-put-is-sws simple-ws-beg |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1666 rung-end-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1667 (setq rung-is-marked t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1668 (c-put-in-sws (setq simple-ws-beg (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1669 last-put-in-sws-pos simple-ws-beg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1670 rung-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1671 (c-put-is-sws (setq rung-pos simple-ws-beg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1672 (1+ next-rung-pos))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1673 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1674 (c-debug-sws-msg |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1675 "c-backward-sws not caching [%s..%s] - [%s..%s] (min %s)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1676 (point) (1+ next-rung-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1677 simple-ws-beg (min (1+ rung-pos) (point-max)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1678 (point-min)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1679 (setq rung-pos next-rung-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1680 simple-ws-beg (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1681 )) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1682 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1683 ;; Make sure that the newly marked `c-in-sws' region doesn't connect to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1684 ;; another one before the point (which might occur when editing inside a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1685 ;; comment or macro). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1686 (when (eq last-put-in-sws-pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1687 (cond ((< (point-min) last-put-in-sws-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1688 (c-debug-sws-msg |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1689 "c-backward-sws clearing at %s for cache separation" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1690 (1- last-put-in-sws-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1691 (c-remove-in-sws (1- last-put-in-sws-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1692 last-put-in-sws-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1693 ((> (point-min) 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1694 ;; If at bob and the buffer is narrowed, we have to clear the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1695 ;; character we're standing on instead since there might be a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1696 ;; `c-in-sws' before (point-min). In this case it's necessary |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1697 ;; to clear both properties. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1698 (c-debug-sws-msg |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1699 "c-backward-sws clearing thoroughly at %s for cache separation" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1700 last-put-in-sws-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1701 (c-remove-is-and-in-sws last-put-in-sws-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1702 (1+ last-put-in-sws-pos))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1703 ))) |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
1704 |
18720 | 1705 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1706 ;; A system for handling noteworthy parens before the point. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1707 |
7a3ac6c387fe
CC Mode 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 (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
|
1709 (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
|
1710 ;; 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
|
1711 ;; 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
|
1712 ;; 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
|
1713 ;; `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
|
1714 ;; 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
|
1715 ;; 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
|
1716 ;; 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
|
1717 ;; 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
|
1718 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1719 (defvar c-state-cache-start 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1720 (make-variable-buffer-local 'c-state-cache-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1721 ;; This is (point-min) when `c-state-cache' was calculated, since a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1722 ;; change of narrowing is likely to affect the parens that are visible |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1723 ;; before the point. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1724 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1725 (defsubst c-invalidate-state-cache (pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1726 ;; Invalidate all info on `c-state-cache' that applies to the buffer |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1727 ;; at POS or higher. This is much like `c-whack-state-after', but |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1728 ;; it never changes a paren pair element into an open paren element. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1729 ;; Doing that would mean that the new open paren wouldn't have the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1730 ;; required preceding paren pair element. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1731 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1732 ;; This function does not do any hidden buffer changes. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1733 (while (and c-state-cache |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1734 (let ((elem (car c-state-cache))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1735 (if (consp elem) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1736 (or (<= pos (car elem)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1737 (< pos (cdr elem))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1738 (<= pos elem)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1739 (setq c-state-cache (cdr c-state-cache)))) |
18720 | 1740 |
1741 (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
|
1742 ;; 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
|
1743 ;; 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
|
1744 ;; 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
|
1745 ;; of the preceding top-level construct if we aren't in one. |
18720 | 1746 ;; |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1747 ;; 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
|
1748 ;; 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
|
1749 ;; the position of an open paren which has not been closed before |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1750 ;; the point. If an element is a cons, it gives the position of a |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1751 ;; 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
|
1752 ;; 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
|
1753 ;; 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
|
1754 ;; 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
|
1755 ;; succession. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1756 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1757 ;; Currently no characters which are given paren syntax with the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1758 ;; syntax-table property are recorded, i.e. angle bracket arglist |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1759 ;; parens are never present here. Note that this might change. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1760 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1761 ;; This function does not do any hidden buffer changes. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1762 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1763 (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
|
1764 (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
|
1765 (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
|
1766 (in-macro-start (or c-macro-start (point))) |
50273
ea06392567c0
(c-parse-state): Added kludge to avoid an infinite loop when Emacs'
Martin Stjernholm <mast@lysator.liu.se>
parents:
47939
diff
changeset
|
1767 old-state last-pos pairs pos save-pos) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1768 (c-invalidate-state-cache (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1769 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1770 ;; If the minimum position has changed due to narrowing then we |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1771 ;; have to fix the tail of `c-state-cache' accordingly. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1772 (unless (= c-state-cache-start (point-min)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1773 (if (> (point-min) c-state-cache-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1774 ;; If point-min has moved forward then we just need to cut |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1775 ;; off a bit of the tail. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1776 (let ((ptr (cons nil c-state-cache)) elem) |
52605
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
1777 (while (and (setq elem (car-safe (cdr ptr))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1778 (>= (if (consp elem) (car elem) elem) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1779 (point-min))) |
52605
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
1780 (setq ptr (cdr ptr))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1781 (when (consp ptr) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1782 (if (eq (cdr ptr) c-state-cache) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1783 (setq c-state-cache nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1784 (setcdr ptr nil)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1785 ;; If point-min has moved backward then we drop the state |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1786 ;; completely. It's possible to do a better job here and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1787 ;; recalculate the top only. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1788 (setq c-state-cache nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1789 (setq c-state-cache-start (point-min))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1790 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1791 ;; 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
|
1792 ;; 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
|
1793 (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
|
1794 (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
|
1795 (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
|
1796 (1+ (car c-state-cache))))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1797 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1798 ;; 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
|
1799 ;; 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
|
1800 ;; 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
|
1801 (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
|
1802 (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
|
1803 (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
|
1804 (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
|
1805 (/= (point) in-macro-start)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1806 (c-invalidate-state-cache (point)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1807 ;; 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
|
1808 (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
|
1809 (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
|
1810 (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
|
1811 (1+ (car c-state-cache)))))))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1812 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1813 (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
|
1814 ;; 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
|
1815 ;; 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
|
1816 ;; 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
|
1817 (or (when last-pos |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1818 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1819 ;; 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
|
1820 ;; 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
|
1821 ;; 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
|
1822 (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
|
1823 (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
|
1824 (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
|
1825 (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
|
1826 (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
|
1827 (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
|
1828 (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
|
1829 (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
|
1830 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
|
1831 (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
|
1832 c-state-cache (cdr c-state-cache)))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1833 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1834 (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
|
1835 ;; 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
|
1836 ;; 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
|
1837 ;; 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
|
1838 (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
|
1839 (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
|
1840 (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
|
1841 c-state-cache)))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1842 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1843 ;; 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
|
1844 ;; 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
|
1845 ;; 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
|
1846 ;; 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
|
1847 ;; 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
|
1848 (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
|
1849 (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
|
1850 (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
|
1851 (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
|
1852 (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
|
1853 (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
|
1854 c-state-cache (cdr c-state-cache))))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1855 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1856 (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
|
1857 (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
|
1858 last-pos)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1859 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1860 (save-excursion |
18720 | 1861 ;; 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
|
1862 ;; 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
|
1863 ;; 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
|
1864 (goto-char here) |
18720 | 1865 (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
|
1866 (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
|
1867 (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
|
1868 (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
|
1869 (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
|
1870 (point)))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1871 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1872 (narrow-to-region (point-min) here) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1873 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1874 (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
|
1875 ;; Find the balanced brace pairs. |
50273
ea06392567c0
(c-parse-state): Added kludge to avoid an infinite loop when Emacs'
Martin Stjernholm <mast@lysator.liu.se>
parents:
47939
diff
changeset
|
1876 (setq save-pos pos |
ea06392567c0
(c-parse-state): Added kludge to avoid an infinite loop when Emacs'
Martin Stjernholm <mast@lysator.liu.se>
parents:
47939
diff
changeset
|
1877 pairs 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
|
1878 (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
|
1879 (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
|
1880 (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
|
1881 (setq pairs (cons (cons last-pos pos) pairs)))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1882 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1883 ;; 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
|
1884 ;; 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
|
1885 (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
|
1886 (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
|
1887 (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
|
1888 (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
|
1889 (setq pairs (cdr pairs))))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1890 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1891 ;; 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
|
1892 (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
|
1893 (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
|
1894 (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
|
1895 ;; 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
|
1896 ;; 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
|
1897 (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
|
1898 (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
|
1899 (setcar pairs (1- (car pairs))) |
46983
35f3b5d4f918
(c-forward-syntactic-ws): Fixed a bug that could cause an infinite
Martin Stjernholm <mast@lysator.liu.se>
parents:
46688
diff
changeset
|
1900 (when (consp (car-safe c-state-cache)) |
35f3b5d4f918
(c-forward-syntactic-ws): Fixed a bug that could cause an infinite
Martin Stjernholm <mast@lysator.liu.se>
parents:
46688
diff
changeset
|
1901 ;; There could already be a cons first in `c-state-cache' |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1902 ;; if we've e.g. jumped over an unbalanced open paren in a |
46983
35f3b5d4f918
(c-forward-syntactic-ws): Fixed a bug that could cause an infinite
Martin Stjernholm <mast@lysator.liu.se>
parents:
46688
diff
changeset
|
1903 ;; macro below. |
35f3b5d4f918
(c-forward-syntactic-ws): Fixed a bug that could cause an infinite
Martin Stjernholm <mast@lysator.liu.se>
parents:
46688
diff
changeset
|
1904 (setq c-state-cache (cdr c-state-cache))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1905 (setq c-state-cache (cons pairs c-state-cache))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1906 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1907 (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
|
1908 ;; Prepare to loop, but record the open paren only if it's |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1909 ;; outside a macro or within the same macro as point, and |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
1910 ;; if it is a legitimate open paren and not some character |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1911 ;; that got an open paren syntax-table property. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1912 (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
|
1913 (setq pos last-pos) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1914 (if (and (or (>= last-pos in-macro-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1915 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1916 (goto-char last-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1917 (not (c-beginning-of-macro)))) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
1918 ;; Check for known types of parens that we want |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
1919 ;; to record. The syntax table is not to be |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
1920 ;; trusted here since the caller might be using |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
1921 ;; e.g. `c++-template-syntax-table'. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
1922 (memq (char-before last-pos) '(?{ ?\( ?\[))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1923 (setq c-state-cache (cons (1- last-pos) c-state-cache)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1924 |
44728
7a3ac6c387fe
CC Mode 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 (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
|
1926 ;; 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
|
1927 ;; 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
|
1928 ;; 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
|
1929 (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
|
1930 (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
|
1931 c-state-cache nil) |
50273
ea06392567c0
(c-parse-state): Added kludge to avoid an infinite loop when Emacs'
Martin Stjernholm <mast@lysator.liu.se>
parents:
47939
diff
changeset
|
1932 (when (or (not pos) |
ea06392567c0
(c-parse-state): Added kludge to avoid an infinite loop when Emacs'
Martin Stjernholm <mast@lysator.liu.se>
parents:
47939
diff
changeset
|
1933 ;; Emacs (up to at least 21.2) can get confused by |
ea06392567c0
(c-parse-state): Added kludge to avoid an infinite loop when Emacs'
Martin Stjernholm <mast@lysator.liu.se>
parents:
47939
diff
changeset
|
1934 ;; open parens in column zero inside comments: The |
ea06392567c0
(c-parse-state): Added kludge to avoid an infinite loop when Emacs'
Martin Stjernholm <mast@lysator.liu.se>
parents:
47939
diff
changeset
|
1935 ;; sexp functions can then misbehave and bring us |
ea06392567c0
(c-parse-state): Added kludge to avoid an infinite loop when Emacs'
Martin Stjernholm <mast@lysator.liu.se>
parents:
47939
diff
changeset
|
1936 ;; back to the same point again. Check this so that |
ea06392567c0
(c-parse-state): Added kludge to avoid an infinite loop when Emacs'
Martin Stjernholm <mast@lysator.liu.se>
parents:
47939
diff
changeset
|
1937 ;; we don't get an infinite loop. |
ea06392567c0
(c-parse-state): Added kludge to avoid an infinite loop when Emacs'
Martin Stjernholm <mast@lysator.liu.se>
parents:
47939
diff
changeset
|
1938 (>= pos save-pos)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1939 (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
|
1940 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
|
1941 (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
|
1942 (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
|
1943 (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
|
1944 (setq pos nil)))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1945 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1946 c-state-cache))) |
18720 | 1947 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1948 ;; 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
|
1949 (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
|
1950 (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
|
1951 (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
|
1952 (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
|
1953 (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
|
1954 (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
|
1955 (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
|
1956 (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
|
1957 (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
|
1958 (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
|
1959 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
|
1960 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
|
1961 (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
|
1962 (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
|
1963 (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
|
1964 (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
|
1965 '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
|
1966 '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
|
1967 (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
|
1968 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1969 (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
|
1970 ;; 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
|
1971 ;; before BUFPOS. Not destructive on PAREN-STATE. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1972 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1973 ;; This function does not do any hidden buffer changes. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1974 (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
|
1975 (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
|
1976 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
|
1977 (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
|
1978 (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
|
1979 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
|
1980 (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
|
1981 (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
|
1982 (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
|
1983 (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
|
1984 (cdr newstate))) |
18720 | 1985 |
44728
7a3ac6c387fe
CC Mode 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 (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
|
1987 ;; 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
|
1988 ;; after BUFPOS. Not destructive on PAREN-STATE. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1989 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
1990 ;; This function does not do any hidden buffer changes. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
1991 (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
|
1992 (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
|
1993 (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
|
1994 (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
|
1995 ;; 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
|
1996 ;; 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
|
1997 ;; 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
|
1998 ;; 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
|
1999 (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
|
2000 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
|
2001 (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
|
2002 ;; 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
|
2003 ;; 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
|
2004 ;; 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
|
2005 ;; 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
|
2006 ;; 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
|
2007 (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
|
2008 ;; 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
|
2009 ;; 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
|
2010 ;; 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
|
2011 (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
|
2012 (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
|
2013 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
|
2014 ;; 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
|
2015 (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
|
2016 (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
|
2017 nil))) |
18720 | 2018 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2019 (defun c-most-enclosing-brace (paren-state &optional bufpos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2020 ;; Return the bufpos of the innermost enclosing open paren before |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2021 ;; bufpos that hasn't been narrowed out, or nil if none was found. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2022 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2023 ;; This function does not do any hidden buffer changes. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2024 (let (enclosingp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2025 (or bufpos (setq bufpos 134217727)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2026 (while paren-state |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2027 (setq enclosingp (car paren-state) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2028 paren-state (cdr paren-state)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2029 (if (or (consp enclosingp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2030 (>= enclosingp bufpos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2031 (setq enclosingp nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2032 (if (< enclosingp (point-min)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2033 (setq enclosingp nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2034 (setq paren-state nil))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2035 enclosingp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2036 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2037 (defun c-least-enclosing-brace (paren-state &optional bufpos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2038 ;; Return the bufpos of the outermost enclosing open paren before |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2039 ;; bufpos that hasn't been narrowed out, or nil if none was found. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2040 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2041 ;; This function does not do any hidden buffer changes. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2042 (let (pos elem) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2043 (or bufpos (setq bufpos 134217727)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2044 (while paren-state |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2045 (setq elem (car paren-state) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2046 paren-state (cdr paren-state)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2047 (unless (or (consp elem) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2048 (>= elem bufpos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2049 (if (>= elem (point-min)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2050 (setq pos elem)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2051 pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2052 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2053 (defun c-safe-position (bufpos paren-state) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2054 ;; Return the closest known safe position higher up than BUFPOS, or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2055 ;; nil if PAREN-STATE doesn't contain one. Return nil if BUFPOS is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2056 ;; nil, which is useful to find the closest limit before a given |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2057 ;; limit that might be nil. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2058 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2059 ;; This function does not do any hidden buffer changes. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2060 (when bufpos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2061 (let (elem) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2062 (catch 'done |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2063 (while paren-state |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2064 (setq elem (car paren-state)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2065 (if (consp elem) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2066 (cond ((< (cdr elem) bufpos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2067 (throw 'done (cdr elem))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2068 ((< (car elem) bufpos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2069 ;; See below. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2070 (throw 'done (min (1+ (car elem)) bufpos)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2071 (if (< elem bufpos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2072 ;; elem is the position at and not after the opening paren, so |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2073 ;; we can go forward one more step unless it's equal to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2074 ;; bufpos. This is useful in some cases avoid an extra paren |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2075 ;; level between the safe position and bufpos. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2076 (throw 'done (min (1+ elem) bufpos)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2077 (setq paren-state (cdr paren-state))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2078 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2079 (defun c-beginning-of-syntax () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2080 ;; This is used for `font-lock-beginning-of-syntax-function'. It |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2081 ;; goes to the closest previous point that is known to be outside |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2082 ;; any string literal or comment. `c-state-cache' is used if it has |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2083 ;; a position in the vicinity. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2084 (let* ((paren-state c-state-cache) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2085 elem |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2086 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2087 (pos (catch 'done |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2088 ;; Note: Similar code in `c-safe-position'. The |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2089 ;; difference is that we accept a safe position at |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2090 ;; the point and don't bother to go forward past open |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2091 ;; parens. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2092 (while paren-state |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2093 (setq elem (car paren-state)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2094 (if (consp elem) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2095 (cond ((<= (cdr elem) (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2096 (throw 'done (cdr elem))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2097 ((<= (car elem) (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2098 (throw 'done (car elem)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2099 (if (<= elem (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2100 (throw 'done elem))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2101 (setq paren-state (cdr paren-state))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2102 (point-min)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2103 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2104 (if (> pos (- (point) 4000)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2105 (goto-char pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2106 ;; The position is far back. Try `c-beginning-of-defun-1' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2107 ;; (although we can't be entirely sure it will go to a position |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2108 ;; outside a comment or string in current emacsen). FIXME: |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2109 ;; Consult `syntax-ppss' here. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2110 (c-beginning-of-defun-1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2111 (if (< (point) pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2112 (goto-char pos))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2113 |
18720 | 2114 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2115 ;; Tools for scanning identifiers and other tokens. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2116 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2117 (defun c-on-identifier () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2118 "Return non-nil if the point is on or directly after an identifier. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2119 Keywords are recognized and not considered identifiers. If an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2120 identifier is detected, the returned value is its starting position. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2121 If an identifier both starts and stops at the point \(can only happen |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2122 in Pike) then the point for the preceding one is returned. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2123 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2124 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2125 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2126 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2127 (if (zerop (skip-syntax-backward "w_")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2128 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2129 (when (c-major-mode-is 'pike-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2130 ;; Handle the `<operator> syntax in Pike. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2131 (let ((pos (point))) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2132 (skip-chars-backward "-!%&*+/<=>^|~[]()") |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2133 (and (if (< (skip-chars-backward "`") 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2134 t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2135 (goto-char pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2136 (eq (char-after) ?\`)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2137 (looking-at c-symbol-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2138 (>= (match-end 0) pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2139 (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2140 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2141 (and (not (looking-at c-keywords-regexp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2142 (point))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2143 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2144 (defsubst c-simple-skip-symbol-backward () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2145 ;; If the point is at the end of a symbol then skip backward to the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2146 ;; beginning of it. Don't move otherwise. Return non-nil if point |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2147 ;; moved. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2148 (or (< (skip-syntax-backward "w_") 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2149 (and (c-major-mode-is 'pike-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2150 ;; Handle the `<operator> syntax in Pike. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2151 (let ((pos (point))) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2152 (if (and (< (skip-chars-backward "-!%&*+/<=>^|~[]()") 0) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2153 (< (skip-chars-backward "`") 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2154 (looking-at c-symbol-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2155 (>= (match-end 0) pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2156 t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2157 (goto-char pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2158 nil))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2159 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2160 (defsubst c-beginning-of-current-token (&optional back-limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2161 ;; Move to the beginning of the current token. Do not move if not |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2162 ;; in the middle of one. BACK-LIMIT may be used to bound the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2163 ;; backward search; if given it's assumed to be at the boundary |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2164 ;; between two tokens. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2165 (if (looking-at "\\w\\|\\s_") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2166 (skip-syntax-backward "w_" back-limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2167 (let ((start (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2168 (when (< (skip-syntax-backward ".()" back-limit) 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2169 (while (let ((pos (or (and (looking-at c-nonsymbol-token-regexp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2170 (match-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2171 ;; `c-nonsymbol-token-regexp' should always match |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2172 ;; since we've skipped backward over punctuator |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2173 ;; or paren syntax, but consume one char in case |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2174 ;; it doesn't so that we don't leave point before |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2175 ;; some earlier incorrect token. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2176 (1+ (point))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2177 (if (<= pos start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2178 (goto-char pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2179 (< pos start))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2180 |
52107
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
2181 (defun c-end-of-current-token (&optional back-limit) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2182 ;; Move to the end of the current token. Do not move if not in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2183 ;; middle of one. BACK-LIMIT may be used to bound the backward |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2184 ;; search; if given it's assumed to be at the boundary between two |
52107
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
2185 ;; tokens. Return non-nil if the point is moved, nil otherwise. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2186 (let ((start (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2187 (cond ((< (skip-syntax-backward "w_" (1- start)) 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2188 (skip-syntax-forward "w_")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2189 ((< (skip-syntax-backward ".()" back-limit) 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2190 (while (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2191 (if (looking-at c-nonsymbol-token-regexp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2192 (goto-char (match-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2193 ;; `c-nonsymbol-token-regexp' should always match since |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2194 ;; we've skipped backward over punctuator or paren |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2195 ;; syntax, but move forward in case it doesn't so that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2196 ;; we don't leave point earlier than we started with. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2197 (forward-char)) |
52107
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
2198 (< (point) start))))) |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
2199 (> (point) start))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2200 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2201 (defconst c-jump-syntax-balanced |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2202 (if (memq 'gen-string-delim c-emacs-features) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2203 "\\w\\|\\s_\\|\\s\(\\|\\s\)\\|\\s\"\\|\\s|" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2204 "\\w\\|\\s_\\|\\s\(\\|\\s\)\\|\\s\"")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2205 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2206 (defconst c-jump-syntax-unbalanced |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2207 (if (memq 'gen-string-delim c-emacs-features) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2208 "\\w\\|\\s_\\|\\s\"\\|\\s|" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2209 "\\w\\|\\s_\\|\\s\"")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2210 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2211 (defun c-forward-token-2 (&optional count balanced limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2212 "Move forward by tokens. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2213 A token is defined as all symbols and identifiers which aren't |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2214 syntactic whitespace \(note that multicharacter tokens like \"==\" are |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2215 treated properly). Point is always either left at the beginning of a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2216 token or not moved at all. COUNT specifies the number of tokens to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2217 move; a negative COUNT moves in the opposite direction. A COUNT of 0 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2218 moves to the next token beginning only if not already at one. If |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2219 BALANCED is true, move over balanced parens, otherwise move into them. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2220 Also, if BALANCED is true, never move out of an enclosing paren. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2221 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2222 LIMIT sets the limit for the movement and defaults to the point limit. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2223 The case when LIMIT is set in the middle of a token, comment or macro |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2224 is handled correctly, i.e. the point won't be left there. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2225 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2226 Return the number of tokens left to move \(positive or negative). If |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2227 BALANCED is true, a move over a balanced paren counts as one. Note |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2228 that if COUNT is 0 and no appropriate token beginning is found, 1 will |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2229 be returned. Thus, a return value of 0 guarantees that point is at |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2230 the requested position and a return value less \(without signs) than |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2231 COUNT guarantees that point is at the beginning of some token." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2232 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2233 (or count (setq count 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2234 (if (< count 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2235 (- (c-backward-token-2 (- count) balanced limit)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2236 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2237 (let ((jump-syntax (if balanced |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2238 c-jump-syntax-balanced |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2239 c-jump-syntax-unbalanced)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2240 (last (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2241 (prev (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2242 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2243 (if (zerop count) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2244 ;; If count is zero we should jump if in the middle of a token. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2245 (c-end-of-current-token)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2246 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2247 (save-restriction |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2248 (if limit (narrow-to-region (point-min) limit)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2249 (if (/= (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2250 (progn (c-forward-syntactic-ws) (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2251 ;; Skip whitespace. Count this as a move if we did in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2252 ;; fact move. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2253 (setq count (max (1- count) 0))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2254 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2255 (if (eobp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2256 ;; Moved out of bounds. Make sure the returned count isn't zero. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2257 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2258 (if (zerop count) (setq count 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2259 (goto-char last)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2260 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2261 ;; Use `condition-case' to avoid having the limit tests |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2262 ;; inside the loop. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2263 (condition-case nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2264 (while (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2265 (> count 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2266 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2267 (setq last (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2268 (cond ((looking-at jump-syntax) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2269 (goto-char (scan-sexps (point) 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2270 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2271 ((looking-at c-nonsymbol-token-regexp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2272 (goto-char (match-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2273 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2274 ;; `c-nonsymbol-token-regexp' above should always |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2275 ;; match if there are correct tokens. Try to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2276 ;; widen to see if the limit was set in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2277 ;; middle of one, else fall back to treating |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2278 ;; the offending thing as a one character token. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2279 ((and limit |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2280 (save-restriction |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2281 (widen) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2282 (looking-at c-nonsymbol-token-regexp))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2283 nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2284 (t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2285 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2286 t)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2287 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2288 (setq prev last |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2289 count (1- count))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2290 (error (goto-char last))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2291 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2292 (when (eobp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2293 (goto-char prev) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2294 (setq count (1+ count))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2295 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2296 count))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2297 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2298 (defun c-backward-token-2 (&optional count balanced limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2299 "Move backward by tokens. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2300 See `c-forward-token-2' for details." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2301 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2302 (or count (setq count 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2303 (if (< count 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2304 (- (c-forward-token-2 (- count) balanced limit)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2305 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2306 (or limit (setq limit (point-min))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2307 (let ((jump-syntax (if balanced |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2308 c-jump-syntax-balanced |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2309 c-jump-syntax-unbalanced)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2310 (last (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2311 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2312 (if (zerop count) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2313 ;; The count is zero so try to skip to the beginning of the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2314 ;; current token. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2315 (if (> (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2316 (progn (c-beginning-of-current-token) (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2317 (if (< (point) limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2318 ;; The limit is inside the same token, so return 1. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2319 (setq count 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2320 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2321 ;; We're not in the middle of a token. If there's |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2322 ;; whitespace after the point then we must move backward, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2323 ;; so set count to 1 in that case. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2324 (and (looking-at c-syntactic-ws-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2325 ;; If we're looking at a '#' that might start a cpp |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2326 ;; directive then we have to do a more elaborate check. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2327 (or (/= (char-after) ?#) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2328 (not c-opt-cpp-prefix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2329 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2330 (and (= (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2331 (progn (beginning-of-line) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2332 (looking-at "[ \t]*") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2333 (match-end 0))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2334 (or (bobp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2335 (progn (backward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2336 (not (eq (char-before) ?\\))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2337 (setq count 1)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2338 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2339 ;; Use `condition-case' to avoid having to check for buffer |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2340 ;; limits in `backward-char', `scan-sexps' and `goto-char' below. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2341 (condition-case nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2342 (while (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2343 (> count 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2344 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2345 (c-backward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2346 (backward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2347 (if (looking-at jump-syntax) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2348 (goto-char (scan-sexps (1+ (point)) -1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2349 ;; This can be very inefficient if there's a long |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2350 ;; sequence of operator tokens without any separation. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2351 ;; That doesn't happen in practice, anyway. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2352 (c-beginning-of-current-token)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2353 (>= (point) limit))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2354 (setq last (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2355 count (1- count))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2356 (error (goto-char last))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2357 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2358 (if (< (point) limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2359 (goto-char last)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2360 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2361 count))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2362 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2363 (defun c-forward-token-1 (&optional count balanced limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2364 "Like `c-forward-token-2' but doesn't treat multicharacter operator |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2365 tokens like \"==\" as single tokens, i.e. all sequences of symbol |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2366 characters are jumped over character by character. This function is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2367 for compatibility only; it's only a wrapper over `c-forward-token-2'." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2368 (let ((c-nonsymbol-token-regexp "\\s.\\|\\s\(\\|\\s\)")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2369 (c-forward-token-2 count balanced limit))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2370 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2371 (defun c-backward-token-1 (&optional count balanced limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2372 "Like `c-backward-token-2' but doesn't treat multicharacter operator |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2373 tokens like \"==\" as single tokens, i.e. all sequences of symbol |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2374 characters are jumped over character by character. This function is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2375 for compatibility only; it's only a wrapper over `c-backward-token-2'." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2376 (let ((c-nonsymbol-token-regexp "\\s.\\|\\s\(\\|\\s\)")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2377 (c-backward-token-2 count balanced limit))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2378 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2379 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2380 ;; Tools for doing searches restricted to syntactically relevant text. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2381 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2382 (defun c-syntactic-re-search-forward (regexp &optional bound noerror |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2383 paren-level not-inside-token |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2384 lookbehind-submatch) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2385 "Like `re-search-forward', but only report matches that are found |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2386 in syntactically significant text. I.e. matches in comments, macros |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2387 or string literals are ignored. The start point is assumed to be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2388 outside any comment, macro or string literal, or else the content of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2389 that region is taken as syntactically significant text. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2390 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2391 If PAREN-LEVEL is non-nil, an additional restriction is added to |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2392 ignore matches in nested paren sexps. The search will also not go |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2393 outside the current list sexp, which has the effect that if the point |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2394 should be moved to BOUND when no match is found \(i.e. NOERROR is |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2395 neither nil nor t), then it will be at the closing paren if the end of |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2396 the current list sexp is encountered first. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2397 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2398 If NOT-INSIDE-TOKEN is non-nil, matches in the middle of tokens are |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2399 ignored. Things like multicharacter operators and special symbols |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2400 \(e.g. \"`()\" in Pike) are handled but currently not floating point |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2401 constants. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2402 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2403 If LOOKBEHIND-SUBMATCH is non-nil, it's taken as a number of a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2404 subexpression in REGEXP. The end of that submatch is used as the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2405 position to check for syntactic significance. If LOOKBEHIND-SUBMATCH |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2406 isn't used or if that subexpression didn't match then the start |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2407 position of the whole match is used instead. The \"look behind\" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2408 subexpression is never tested before the starting position, so it |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2409 might be a good idea to include \\=\\= as a match alternative in it. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2410 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2411 Optimization note: Matches might be missed if the \"look behind\" |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2412 subexpression can match the end of nonwhite syntactic whitespace, |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2413 i.e. the end of comments or cpp directives. This since the function |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2414 skips over such things before resuming the search. It's on the other |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2415 hand not safe to assume that the \"look behind\" subexpression never |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2416 matches syntactic whitespace. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2417 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2418 Bug: Unbalanced parens inside cpp directives are currently not handled |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2419 correctly \(i.e. they don't get ignored as they should) when |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2420 PAREN-LEVEL is set." |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2421 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2422 (or bound (setq bound (point-max))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2423 (if paren-level (setq paren-level -1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2424 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2425 ;;(message "c-syntactic-re-search-forward %s %s %S" (point) bound regexp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2426 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2427 (let ((start (point)) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2428 tmp |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2429 ;; Start position for the last search. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2430 search-pos |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2431 ;; The `parse-partial-sexp' state between the start position |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2432 ;; and the point. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2433 state |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2434 ;; The current position after the last state update. The next |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2435 ;; `parse-partial-sexp' continues from here. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2436 (state-pos (point)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2437 ;; The position at which to check the state and the state |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2438 ;; there. This is separate from `state-pos' since we might |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2439 ;; need to back up before doing the next search round. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2440 check-pos check-state |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2441 ;; Last position known to end a token. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2442 (last-token-end-pos (point-min)) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2443 ;; Set when a valid match is found. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2444 found) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2445 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2446 (condition-case err |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2447 (while |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2448 (and |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2449 (progn |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2450 (setq search-pos (point)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2451 (re-search-forward regexp bound noerror)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2452 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2453 (progn |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2454 (setq state (parse-partial-sexp |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2455 state-pos (match-beginning 0) paren-level nil state) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2456 state-pos (point)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2457 (if (setq check-pos (and lookbehind-submatch |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2458 (or (not paren-level) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2459 (>= (car state) 0)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2460 (match-end lookbehind-submatch))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2461 (setq check-state (parse-partial-sexp |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2462 state-pos check-pos paren-level nil state)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2463 (setq check-pos state-pos |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2464 check-state state)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2465 |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2466 ;; NOTE: If we got a look behind subexpression and get |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2467 ;; an insignificant match in something that isn't |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2468 ;; syntactic whitespace (i.e. strings or in nested |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2469 ;; parentheses), then we can never skip more than a |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2470 ;; single character from the match start position |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2471 ;; (i.e. `state-pos' here) before continuing the |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2472 ;; search. That since the look behind subexpression |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2473 ;; might match the end of the insignificant region in |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2474 ;; the next search. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2475 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2476 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2477 ((elt check-state 7) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2478 ;; Match inside a line comment. Skip to eol. Use |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2479 ;; `re-search-forward' instead of `skip-chars-forward' to get |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2480 ;; the right bound behavior. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2481 (re-search-forward "[\n\r]" bound noerror)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2482 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2483 ((elt check-state 4) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2484 ;; Match inside a block comment. Skip to the '*/'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2485 (search-forward "*/" bound noerror)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2486 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2487 ((and (not (elt check-state 5)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2488 (eq (char-before check-pos) ?/) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2489 (not (c-get-char-property (1- check-pos) 'syntax-table)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2490 (memq (char-after check-pos) '(?/ ?*))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2491 ;; Match in the middle of the opener of a block or line |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2492 ;; comment. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2493 (if (= (char-after check-pos) ?/) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2494 (re-search-forward "[\n\r]" bound noerror) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2495 (search-forward "*/" bound noerror))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2496 |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2497 ;; The last `parse-partial-sexp' above might have |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2498 ;; stopped short of the real check position if the end |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2499 ;; of the current sexp was encountered in paren-level |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2500 ;; mode. The checks above are always false in that |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2501 ;; case, and since they can do better skipping in |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2502 ;; lookbehind-submatch mode, we do them before |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2503 ;; checking the paren level. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2504 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2505 ((and paren-level |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2506 (/= (setq tmp (car check-state)) 0)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2507 ;; Check the paren level first since we're short of the |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2508 ;; syntactic checking position if the end of the |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2509 ;; current sexp was encountered by `parse-partial-sexp'. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2510 (if (> tmp 0) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2511 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2512 ;; Inside a nested paren sexp. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2513 (if lookbehind-submatch |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2514 ;; See the NOTE above. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2515 (progn (goto-char state-pos) t) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2516 ;; Skip out of the paren quickly. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2517 (setq state (parse-partial-sexp state-pos bound 0 nil state) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2518 state-pos (point))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2519 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2520 ;; Have exited the current paren sexp. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2521 (if noerror |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2522 (progn |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2523 ;; The last `parse-partial-sexp' call above |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2524 ;; has left us just after the closing paren |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2525 ;; in this case, so we can modify the bound |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2526 ;; to leave the point at the right position |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2527 ;; upon return. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2528 (setq bound (1- (point))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2529 nil) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2530 (signal 'search-failed (list regexp))))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2531 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2532 ((setq tmp (elt check-state 3)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2533 ;; Match inside a string. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2534 (if (or lookbehind-submatch |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2535 (not (integerp tmp))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2536 ;; See the NOTE above. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2537 (progn (goto-char state-pos) t) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2538 ;; Skip to the end of the string before continuing. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2539 (let ((ender (make-string 1 tmp)) (continue t)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2540 (while (if (search-forward ender bound noerror) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2541 (progn |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2542 (setq state (parse-partial-sexp |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2543 state-pos (point) nil nil state) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2544 state-pos (point)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2545 (elt state 3)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2546 (setq continue nil))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2547 continue))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2548 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2549 ((save-excursion |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2550 (save-match-data |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2551 (c-beginning-of-macro start))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2552 ;; Match inside a macro. Skip to the end of it. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2553 (c-end-of-macro) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2554 (cond ((<= (point) bound) t) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2555 (noerror nil) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2556 (t (signal 'search-failed (list regexp))))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2557 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2558 ((and not-inside-token |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2559 (or (< check-pos last-token-end-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2560 (< check-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2561 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2562 (goto-char check-pos) |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
2563 (save-match-data |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
2564 (c-end-of-current-token last-token-end-pos)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2565 (setq last-token-end-pos (point)))))) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2566 ;; Inside a token. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2567 (if lookbehind-submatch |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2568 ;; See the NOTE above. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2569 (goto-char state-pos) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2570 (goto-char (min last-token-end-pos bound)))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2571 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2572 (t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2573 ;; A real match. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2574 (setq found t) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2575 nil))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2576 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2577 ;; Should loop to search again, but take care to avoid |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2578 ;; looping on the same spot. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2579 (or (/= search-pos (point)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2580 (if (= (point) bound) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2581 (if noerror |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2582 nil |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2583 (signal 'search-failed (list regexp))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2584 (forward-char) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2585 t)))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2586 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2587 (error |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2588 (goto-char start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2589 (signal (car err) (cdr err)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2590 |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2591 ;;(message "c-syntactic-re-search-forward done %s" (or (match-end 0) (point))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2592 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2593 (if found |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2594 (progn |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2595 (goto-char (match-end 0)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2596 (match-end 0)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2597 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2598 ;; Search failed. Set point as appropriate. |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2599 (if (eq noerror t) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2600 (goto-char start) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
2601 (goto-char bound)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2602 nil))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2603 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2604 (defun c-syntactic-skip-backward (skip-chars &optional limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2605 "Like `skip-chars-backward' but only look at syntactically relevant chars, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2606 i.e. don't stop at positions inside syntactic whitespace or string |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2607 literals. Preprocessor directives are also ignored, with the exception |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2608 of the one that the point starts within, if any. If LIMIT is given, |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
2609 it's assumed to be at a syntactically relevant position." |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2610 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2611 (let ((start (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2612 ;; A list of syntactically relevant positions in descending |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2613 ;; order. It's used to avoid scanning repeatedly over |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2614 ;; potentially large regions with `parse-partial-sexp' to verify |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2615 ;; each position. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2616 safe-pos-list |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2617 ;; The result from `c-beginning-of-macro' at the start position or the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2618 ;; start position itself if it isn't within a macro. Evaluated on |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2619 ;; demand. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2620 start-macro-beg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2621 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2622 (while (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2623 (while (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2624 (< (skip-chars-backward skip-chars limit) 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2625 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2626 ;; Use `parse-partial-sexp' from a safe position down to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2627 ;; the point to check if it's outside comments and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2628 ;; strings. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2629 (let ((pos (point)) safe-pos state) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2630 ;; Pick a safe position as close to the point as |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2631 ;; possible. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2632 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2633 ;; FIXME: Consult `syntax-ppss' here if our |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2634 ;; cache doesn't give a good position. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2635 (while (and safe-pos-list |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2636 (> (car safe-pos-list) (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2637 (setq safe-pos-list (cdr safe-pos-list))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2638 (unless (setq safe-pos (car-safe safe-pos-list)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2639 (setq safe-pos (max (or (c-safe-position |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2640 (point) (or c-state-cache |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2641 (c-parse-state))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2642 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2643 (point-min)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2644 safe-pos-list (list safe-pos))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2645 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2646 (while (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2647 (setq state (parse-partial-sexp |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2648 safe-pos pos 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2649 (< (point) pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2650 ;; Cache positions along the way to use if we have to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2651 ;; back up more. Every closing paren on the same |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2652 ;; level seems like fairly well spaced positions. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2653 (setq safe-pos (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2654 safe-pos-list (cons safe-pos safe-pos-list))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2655 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2656 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2657 ((or (elt state 3) (elt state 4)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2658 ;; Inside string or comment. Continue search at the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2659 ;; beginning of it. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2660 (if (setq pos (nth 8 state)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2661 ;; It's an emacs where `parse-partial-sexp' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2662 ;; supplies the starting position. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2663 (goto-char pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2664 (goto-char (car (c-literal-limits safe-pos)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2665 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2666 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2667 ((c-beginning-of-macro limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2668 ;; Inside a macro. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2669 (if (< (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2670 (or start-macro-beg |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2671 (setq start-macro-beg |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2672 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2673 (goto-char start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2674 (c-beginning-of-macro limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2675 (point))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2676 t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2677 ;; It's inside the same macro we started in so it's |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2678 ;; a relevant match. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2679 (goto-char pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2680 nil)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2681 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2682 (> (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2683 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2684 ;; Skip syntactic ws afterwards so that we don't stop at the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2685 ;; end of a comment if `skip-chars' is something like "^/". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2686 (c-backward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2687 (point))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2688 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2689 (- (point) start))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2690 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2691 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2692 ;; Tools for handling comments and string literals. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2693 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2694 (defun c-slow-in-literal (&optional lim detect-cpp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2695 "Return the type of literal point is in, if any. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2696 The return value is `c' if in a C-style comment, `c++' if in a C++ |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2697 style comment, `string' if in a string literal, `pound' if DETECT-CPP |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2698 is non-nil and in a preprocessor line, or nil if somewhere else. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2699 Optional LIM is used as the backward limit of the search. If omitted, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2700 or nil, `c-beginning-of-defun' is used. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2701 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2702 The last point calculated is cached if the cache is enabled, i.e. if |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2703 `c-in-literal-cache' is bound to a two element vector. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2704 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2705 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2706 (if (and (vectorp c-in-literal-cache) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2707 (= (point) (aref c-in-literal-cache 0))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2708 (aref c-in-literal-cache 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2709 (let ((rtn (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2710 (let* ((pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2711 (lim (or lim (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2712 (c-beginning-of-syntax) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2713 (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2714 (state (parse-partial-sexp lim pos))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2715 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2716 ((elt state 3) 'string) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2717 ((elt state 4) (if (elt state 7) 'c++ 'c)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2718 ((and detect-cpp (c-beginning-of-macro lim)) 'pound) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2719 (t nil)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2720 ;; cache this result if the cache is enabled |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2721 (if (not c-in-literal-cache) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2722 (setq c-in-literal-cache (vector (point) rtn))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2723 rtn))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2724 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2725 ;; XEmacs has a built-in function that should make this much quicker. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2726 ;; I don't think we even need the cache, which makes our lives more |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2727 ;; complicated anyway. In this case, lim is only used to detect |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2728 ;; cpp directives. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2729 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2730 ;; Note that there is a bug in Xemacs's buffer-syntactic-context when used in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2731 ;; conjunction with syntax-table-properties. The bug is present in, e.g., |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2732 ;; Xemacs 21.4.4. It manifested itself thus: |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2733 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2734 ;; Starting with an empty AWK Mode buffer, type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2735 ;; /regexp/ {<C-j> |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2736 ;; Point gets wrongly left at column 0, rather than being indented to tab-width. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2737 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2738 ;; AWK Mode is designed such that when the first / is typed, it gets the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2739 ;; syntax-table property "string fence". When the second / is typed, BOTH /s |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2740 ;; are given the s-t property "string". However, buffer-syntactic-context |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2741 ;; fails to take account of the change of the s-t property on the opening / to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2742 ;; "string", and reports that the { is within a string started by the second /. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2743 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2744 ;; The workaround for this is for the AWK Mode initialisation to switch the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2745 ;; defalias for c-in-literal to c-slow-in-literal. This will slow down other |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2746 ;; cc-modes in Xemacs whenever an awk-buffer has been initialised. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2747 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2748 ;; (Alan Mackenzie, 2003/4/30). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2749 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2750 (defun c-fast-in-literal (&optional lim detect-cpp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2751 (let ((context (buffer-syntactic-context))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2752 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2753 ((eq context 'string) 'string) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2754 ((eq context 'comment) 'c++) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2755 ((eq context 'block-comment) 'c) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2756 ((and detect-cpp (save-excursion (c-beginning-of-macro lim))) 'pound)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2757 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2758 (defalias 'c-in-literal |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2759 (if (fboundp 'buffer-syntactic-context) |
51829
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2760 'c-fast-in-literal ; XEmacs |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2761 'c-slow-in-literal)) ; GNU Emacs |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2762 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2763 ;; The defalias above isn't enough to shut up the byte compiler. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2764 (cc-bytecomp-defun c-in-literal) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2765 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2766 (defun c-literal-limits (&optional lim near not-in-delimiter) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2767 "Return a cons of the beginning and end positions of the comment or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2768 string surrounding point (including both delimiters), or nil if point |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2769 isn't in one. If LIM is non-nil, it's used as the \"safe\" position |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2770 to start parsing from. If NEAR is non-nil, then the limits of any |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2771 literal next to point is returned. \"Next to\" means there's only |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2772 spaces and tabs between point and the literal. The search for such a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2773 literal is done first in forward direction. If NOT-IN-DELIMITER is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2774 non-nil, the case when point is inside a starting delimiter won't be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2775 recognized. This only has effect for comments, which have starting |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2776 delimiters with more than one character. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2777 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2778 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2779 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2780 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2781 (let* ((pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2782 (lim (or lim (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2783 (c-beginning-of-syntax) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2784 (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2785 (state (parse-partial-sexp lim pos))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2786 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2787 (cond ((elt state 3) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2788 ;; String. Search backward for the start. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2789 (while (elt state 3) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2790 (search-backward (make-string 1 (elt state 3))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2791 (setq state (parse-partial-sexp lim (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2792 (cons (point) (or (c-safe (c-forward-sexp 1) (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2793 (point-max)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2794 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2795 ((elt state 7) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2796 ;; Line comment. Search from bol for the comment starter. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2797 (beginning-of-line) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2798 (setq state (parse-partial-sexp lim (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2799 lim (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2800 (while (not (elt state 7)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2801 (search-forward "//") ; Should never fail. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2802 (setq state (parse-partial-sexp |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2803 lim (point) nil nil state) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2804 lim (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2805 (backward-char 2) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2806 (cons (point) (progn (c-forward-single-comment) (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2807 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2808 ((elt state 4) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2809 ;; Block comment. Search backward for the comment starter. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2810 (while (elt state 4) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2811 (search-backward "/*") ; Should never fail. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2812 (setq state (parse-partial-sexp lim (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2813 (cons (point) (progn (c-forward-single-comment) (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2814 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2815 ((and (not not-in-delimiter) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2816 (not (elt state 5)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2817 (eq (char-before) ?/) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2818 (looking-at "[/*]")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2819 ;; We're standing in a comment starter. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2820 (backward-char 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2821 (cons (point) (progn (c-forward-single-comment) (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2822 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2823 (near |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2824 (goto-char pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2825 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2826 ;; Search forward for a literal. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2827 (skip-chars-forward " \t") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2828 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2829 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2830 ((looking-at c-string-limit-regexp) ; String. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2831 (cons (point) (or (c-safe (c-forward-sexp 1) (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2832 (point-max)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2833 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2834 ((looking-at c-comment-start-regexp) ; Line or block comment. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2835 (cons (point) (progn (c-forward-single-comment) (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2836 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2837 (t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2838 ;; Search backward. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2839 (skip-chars-backward " \t") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2840 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2841 (let ((end (point)) beg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2842 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2843 ((save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2844 (< (skip-syntax-backward c-string-syntax) 0)) ; String. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2845 (setq beg (c-safe (c-backward-sexp 1) (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2846 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2847 ((and (c-safe (forward-char -2) t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2848 (looking-at "*/")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2849 ;; Block comment. Due to the nature of line |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2850 ;; comments, they will always be covered by the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2851 ;; normal case above. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2852 (goto-char end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2853 (c-backward-single-comment) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2854 ;; If LIM is bogus, beg will be bogus. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2855 (setq beg (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2856 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2857 (if beg (cons beg end)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2858 )))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2859 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2860 (defun c-literal-limits-fast (&optional lim near not-in-delimiter) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2861 ;; Like c-literal-limits, but for emacsen whose `parse-partial-sexp' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2862 ;; returns the pos of the comment start. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2863 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2864 "Return a cons of the beginning and end positions of the comment or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2865 string surrounding point (including both delimiters), or nil if point |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2866 isn't in one. If LIM is non-nil, it's used as the \"safe\" position |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2867 to start parsing from. If NEAR is non-nil, then the limits of any |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2868 literal next to point is returned. \"Next to\" means there's only |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2869 spaces and tabs between point and the literal. The search for such a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2870 literal is done first in forward direction. If NOT-IN-DELIMITER is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2871 non-nil, the case when point is inside a starting delimiter won't be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2872 recognized. This only has effect for comments, which have starting |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2873 delimiters with more than one character. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2874 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2875 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2876 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2877 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2878 (let* ((pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2879 (lim (or lim (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2880 (c-beginning-of-syntax) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2881 (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2882 (state (parse-partial-sexp lim pos))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2883 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2884 (cond ((elt state 3) ; String. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2885 (goto-char (elt state 8)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2886 (cons (point) (or (c-safe (c-forward-sexp 1) (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2887 (point-max)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2888 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2889 ((elt state 4) ; Comment. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2890 (goto-char (elt state 8)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2891 (cons (point) (progn (c-forward-single-comment) (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2892 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2893 ((and (not not-in-delimiter) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2894 (not (elt state 5)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2895 (eq (char-before) ?/) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2896 (looking-at "[/*]")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2897 ;; We're standing in a comment starter. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2898 (backward-char 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2899 (cons (point) (progn (c-forward-single-comment) (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2900 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2901 (near |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2902 (goto-char pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2903 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2904 ;; Search forward for a literal. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2905 (skip-chars-forward " \t") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2906 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2907 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2908 ((looking-at c-string-limit-regexp) ; String. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2909 (cons (point) (or (c-safe (c-forward-sexp 1) (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2910 (point-max)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2911 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2912 ((looking-at c-comment-start-regexp) ; Line or block comment. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2913 (cons (point) (progn (c-forward-single-comment) (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2914 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2915 (t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2916 ;; Search backward. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2917 (skip-chars-backward " \t") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2918 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2919 (let ((end (point)) beg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2920 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2921 ((save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2922 (< (skip-syntax-backward c-string-syntax) 0)) ; String. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2923 (setq beg (c-safe (c-backward-sexp 1) (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2924 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2925 ((and (c-safe (forward-char -2) t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2926 (looking-at "*/")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2927 ;; Block comment. Due to the nature of line |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2928 ;; comments, they will always be covered by the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2929 ;; normal case above. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2930 (goto-char end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2931 (c-backward-single-comment) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2932 ;; If LIM is bogus, beg will be bogus. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2933 (setq beg (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2934 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2935 (if beg (cons beg end)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2936 )))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2937 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2938 (if (memq 'pps-extended-state c-emacs-features) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2939 (defalias 'c-literal-limits 'c-literal-limits-fast)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2940 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2941 (defun c-collect-line-comments (range) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2942 "If the argument is a cons of two buffer positions (such as returned by |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2943 `c-literal-limits'), and that range contains a C++ style line comment, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2944 then an extended range is returned that contains all adjacent line |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2945 comments (i.e. all comments that starts in the same column with no |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2946 empty lines or non-whitespace characters between them). Otherwise the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2947 argument is returned. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2948 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2949 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2950 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2951 (condition-case nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2952 (if (and (consp range) (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2953 (goto-char (car range)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2954 (looking-at "//"))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2955 (let ((col (current-column)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2956 (beg (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2957 (bopl (c-point 'bopl)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2958 (end (cdr range))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2959 ;; Got to take care in the backward direction to handle |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2960 ;; comments which are preceded by code. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2961 (while (and (c-backward-single-comment) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2962 (>= (point) bopl) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2963 (looking-at "//") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2964 (= col (current-column))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2965 (setq beg (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2966 bopl (c-point 'bopl))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2967 (goto-char end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2968 (while (and (progn (skip-chars-forward " \t") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2969 (looking-at "//")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2970 (= col (current-column)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2971 (prog1 (zerop (forward-line 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2972 (setq end (point))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2973 (cons beg end)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2974 range) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2975 (error range)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2976 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2977 (defun c-literal-type (range) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2978 "Convenience function that given the result of `c-literal-limits', |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2979 returns nil or the type of literal that the range surrounds. It's |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2980 much faster than using `c-in-literal' and is intended to be used when |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2981 you need both the type of a literal and its limits. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2982 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2983 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2984 (if (consp range) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2985 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2986 (goto-char (car range)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2987 (cond ((looking-at c-string-limit-regexp) 'string) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2988 ((or (looking-at "//") ; c++ line comment |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2989 (and (looking-at "\\s<") ; comment starter |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2990 (looking-at "#"))) ; awk comment. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2991 'c++) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2992 (t 'c))) ; Assuming the range is valid. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2993 range)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2994 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2995 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2996 ;; `c-find-decl-spots' and accompanying stuff. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2997 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2998 ;; Variables used in `c-find-decl-spots' to cache the search done for |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
2999 ;; the first declaration in the last call. When that function starts, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3000 ;; it needs to back up over syntactic whitespace to look at the last |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3001 ;; token before the region being searched. That can sometimes cause |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3002 ;; moves back and forth over a quite large region of comments and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3003 ;; macros, which would be repeated for each changed character when |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3004 ;; we're called during fontification, since font-lock refontifies the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3005 ;; current line for each change. Thus it's worthwhile to cache the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3006 ;; first match. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3007 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3008 ;; `c-find-decl-syntactic-pos' is a syntactically relevant position in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3009 ;; the syntactic whitespace less or equal to some start position. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3010 ;; There's no cached value if it's nil. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3011 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3012 ;; `c-find-decl-match-pos' is the match position if |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3013 ;; `c-find-decl-prefix-search' matched before the syntactic whitespace |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3014 ;; at `c-find-decl-syntactic-pos', or nil if there's no such match. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3015 (defvar c-find-decl-syntactic-pos nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3016 (make-variable-buffer-local 'c-find-decl-syntactic-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3017 (defvar c-find-decl-match-pos nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3018 (make-variable-buffer-local 'c-find-decl-match-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3019 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3020 (defsubst c-invalidate-find-decl-cache (change-min-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3021 (and c-find-decl-syntactic-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3022 (< change-min-pos c-find-decl-syntactic-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3023 (setq c-find-decl-syntactic-pos nil))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3024 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3025 ; (defface c-debug-decl-spot-face |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3026 ; '((t (:background "Turquoise"))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3027 ; "Debug face to mark the spots where `c-find-decl-spots' stopped.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3028 ; (defface c-debug-decl-sws-face |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3029 ; '((t (:background "Khaki"))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3030 ; "Debug face to mark the syntactic whitespace between the declaration |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3031 ; spots and the preceding token end.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3032 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3033 (defmacro c-debug-put-decl-spot-faces (match-pos decl-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3034 (when (facep 'c-debug-decl-spot-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3035 `(let ((match-pos ,match-pos) (decl-pos ,decl-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3036 (c-debug-add-face (max match-pos (point-min)) decl-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3037 'c-debug-decl-sws-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3038 (c-debug-add-face decl-pos (min (1+ decl-pos) (point-max)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3039 'c-debug-decl-spot-face)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3040 (defmacro c-debug-remove-decl-spot-faces (beg end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3041 (when (facep 'c-debug-decl-spot-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3042 `(progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3043 (c-debug-remove-face ,beg ,end 'c-debug-decl-spot-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3044 (c-debug-remove-face ,beg ,end 'c-debug-decl-sws-face)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3045 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3046 (defmacro c-find-decl-prefix-search () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3047 ;; Macro used inside `c-find-decl-spots'. It ought to be a defun, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3048 ;; but it contains lots of free variables that refer to things |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3049 ;; inside `c-find-decl-spots'. The point is left at `cfd-match-pos' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3050 ;; if there is a match, otherwise at `cfd-limit'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3051 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3052 '(progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3053 ;; Find the next property match position if we haven't got one already. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3054 (unless cfd-prop-match |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3055 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3056 (while (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3057 (goto-char (next-single-property-change |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3058 (point) 'c-type nil cfd-limit)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3059 (and (< (point) cfd-limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3060 (not (eq (c-get-char-property (1- (point)) 'c-type) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3061 'c-decl-end))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3062 (setq cfd-prop-match (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3063 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3064 ;; Find the next `c-decl-prefix-re' match if we haven't got one already. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3065 (unless cfd-re-match |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3066 (while (and (setq cfd-re-match |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3067 (re-search-forward c-decl-prefix-re cfd-limit 'move)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3068 (c-got-face-at (1- (setq cfd-re-match (match-end 1))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3069 c-literal-faces)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3070 ;; Search again if the match is within a comment or a string literal. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3071 (while (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3072 (goto-char (next-single-property-change |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3073 cfd-re-match 'face nil cfd-limit)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3074 (and (< (point) cfd-limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3075 (c-got-face-at (point) c-literal-faces))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3076 (setq cfd-re-match (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3077 (unless cfd-re-match |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3078 (setq cfd-re-match cfd-limit))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3079 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3080 ;; Choose whichever match is closer to the start. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3081 (if (< cfd-re-match cfd-prop-match) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3082 (setq cfd-match-pos cfd-re-match |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3083 cfd-re-match nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3084 (setq cfd-match-pos cfd-prop-match |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3085 cfd-prop-match nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3086 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3087 (goto-char cfd-match-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3088 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3089 (when (< cfd-match-pos cfd-limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3090 ;; Skip forward past comments only so we don't skip macros. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3091 (c-forward-comments) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3092 ;; Set the position to continue at. We can avoid going over |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3093 ;; the comments skipped above a second time, but it's possible |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3094 ;; that the comment skipping has taken us past `cfd-prop-match' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3095 ;; since the property might be used inside comments. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3096 (setq cfd-continue-pos (if cfd-prop-match |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3097 (min cfd-prop-match (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3098 (point)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3099 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3100 (defun c-find-decl-spots (cfd-limit cfd-decl-re cfd-face-checklist cfd-fun) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3101 ;; Call CFD-FUN for each possible spot for a declaration from the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3102 ;; point to CFD-LIMIT. A spot for a declaration is the first token |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3103 ;; in the buffer and each token after the ones matched by |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3104 ;; `c-decl-prefix-re' and after the occurrences of the `c-type' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3105 ;; property with the value `c-decl-end' (if `c-type-decl-end-used' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3106 ;; is set). Only a spot that match CFD-DECL-RE and whose face is in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3107 ;; the CFD-FACE-CHECKLIST list causes CFD-FUN to be called. The |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3108 ;; face check is disabled if CFD-FACE-CHECKLIST is nil. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3109 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3110 ;; If the match is inside a macro then the buffer is narrowed to the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3111 ;; end of it, so that CFD-FUN can investigate the following tokens |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3112 ;; without matching something that begins inside a macro and ends |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3113 ;; outside it. It's to avoid this work that the CFD-DECL-RE and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3114 ;; CFD-FACE-CHECKLIST checks exist. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3115 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3116 ;; CFD-FUN is called with point at the start of the spot. It's |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3117 ;; passed two arguments: The first is the end position of the token |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3118 ;; that `c-decl-prefix-re' matched, or 0 for the implicit match at |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3119 ;; bob. The second is a flag that is t when the match is inside a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3120 ;; macro. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3121 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3122 ;; It's assumed that comment and strings are fontified in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3123 ;; searched range. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3124 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3125 ;; This is mainly used in fontification, and so has an elaborate |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3126 ;; cache to handle repeated calls from the same start position; see |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3127 ;; the variables above. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3128 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3129 ;; All variables in this function begin with `cfd-' to avoid name |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3130 ;; collision with the (dynamically bound) variables used in CFD-FUN. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3131 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3132 (let ((cfd-buffer-end (point-max)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3133 ;; The last regexp match found by `c-find-decl-prefix-search'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3134 cfd-re-match |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3135 ;; The last `c-decl-end' found by `c-find-decl-prefix-search'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3136 ;; If searching for the property isn't needed then we disable |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3137 ;; it by faking a first match at the limit. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3138 (cfd-prop-match (unless c-type-decl-end-used cfd-limit)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3139 ;; The position of the last match found by |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3140 ;; `c-find-decl-prefix-search'. For regexp matches it's the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3141 ;; end of the matched token, for property matches it's the end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3142 ;; of the property. 0 for the implicit match at bob. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3143 ;; `cfd-limit' if there's no match. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3144 (cfd-match-pos cfd-limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3145 ;; The position to continue searching at. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3146 cfd-continue-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3147 ;; The position of the last "real" token we've stopped at. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3148 ;; This can be greater than `cfd-continue-pos' when we get |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3149 ;; hits inside macros or at `c-decl-end' positions inside |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3150 ;; comments. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3151 (cfd-token-pos 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3152 ;; The end position of the last entered macro. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3153 (cfd-macro-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3154 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3155 ;; Initialize by finding a syntactically relevant start position |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3156 ;; before the point, and do the first `c-decl-prefix-re' search |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3157 ;; unless we're at bob. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3158 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3159 (let ((start-pos (point)) syntactic-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3160 ;; Must back up a bit since we look for the end of the previous |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3161 ;; statement or declaration, which is earlier than the first |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3162 ;; returned match. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3163 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3164 (when (c-got-face-at (point) c-literal-faces) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3165 ;; But first we need to move to a syntactically relevant |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3166 ;; position. Use the faces to back up to the start of the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3167 ;; comment or string literal. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3168 (when (and (not (bobp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3169 (c-got-face-at (1- (point)) c-literal-faces)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3170 (while (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3171 (goto-char (previous-single-property-change |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3172 (point) 'face nil (point-min))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3173 (and (> (point) (point-min)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3174 (c-got-face-at (point) c-literal-faces))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3175 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3176 ;; XEmacs doesn't fontify the quotes surrounding string |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3177 ;; literals. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3178 (and (featurep 'xemacs) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3179 (eq (get-text-property (point) 'face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3180 'font-lock-string-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3181 (not (bobp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3182 (progn (backward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3183 (not (looking-at c-string-limit-regexp))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3184 (forward-char)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3185 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3186 ;; The font lock package might not have fontified the start of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3187 ;; the literal at all so check that we have arrived at |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3188 ;; something that looks like a start or else resort to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3189 ;; `c-literal-limits'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3190 (unless (looking-at c-literal-start-regexp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3191 (let ((range (c-literal-limits))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3192 (if range (goto-char (car range)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3193 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3194 ;; Must back out of any macro so that we don't miss any |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3195 ;; declaration that could follow after it, unless the limit is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3196 ;; inside the macro. We only check that for the current line to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3197 ;; save some time; it's enough for the by far most common case |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3198 ;; when font-lock refontifies the current line only. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3199 (when (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3200 (and (= (forward-line 1) 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3201 (or (< (c-point 'eol) cfd-limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3202 (progn (backward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3203 (not (eq (char-before) ?\\)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3204 (c-beginning-of-macro)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3205 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3206 ;; Clear the cache if it applied further down. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3207 (c-invalidate-find-decl-cache start-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3208 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3209 (setq syntactic-pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3210 (c-backward-syntactic-ws c-find-decl-syntactic-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3211 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3212 ;; If we hit `c-find-decl-syntactic-pos' and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3213 ;; `c-find-decl-match-pos' is set then we install the cached |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3214 ;; values. If we hit `c-find-decl-syntactic-pos' and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3215 ;; `c-find-decl-match-pos' is nil then we know there's no decl |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3216 ;; prefix in the whitespace before `c-find-decl-syntactic-pos' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3217 ;; and so we can continue the search from this point. If we |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3218 ;; didn't hit `c-find-decl-syntactic-pos' then we're now in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3219 ;; right spot to begin searching anyway. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3220 (if (and (eq (point) c-find-decl-syntactic-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3221 c-find-decl-match-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3222 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3223 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3224 ;; The match is always outside macros and comments so we |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3225 ;; start at the next token. The loop below will later go |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3226 ;; back using `cfd-continue-pos' to fix declarations inside |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3227 ;; the syntactic ws. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3228 (goto-char syntactic-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3229 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3230 (setq cfd-match-pos c-find-decl-match-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3231 cfd-continue-pos syntactic-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3232 (if (< cfd-continue-pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3233 (setq cfd-token-pos (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3234 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3235 (setq c-find-decl-syntactic-pos syntactic-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3236 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3237 (when (if (bobp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3238 ;; Always consider bob a match to get the first declaration |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3239 ;; in the file. Do this separately instead of letting |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3240 ;; `c-decl-prefix-re' match bob, so that it always can |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3241 ;; consume at least one character to ensure that we won't |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3242 ;; get stuck in an infinite loop. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3243 (setq cfd-re-match 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3244 (backward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3245 (c-beginning-of-current-token) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3246 (< (point) cfd-limit)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3247 ;; Do an initial search now. In the bob case above it's only done |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3248 ;; to search for the `c-type' property. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3249 (c-find-decl-prefix-search)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3250 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3251 ;; Advance `cfd-continue-pos' if we got a hit before the start |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3252 ;; position. The earliest position that could affect after |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3253 ;; the start position is the char before the preceding |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3254 ;; comments. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3255 (when (and cfd-continue-pos (< cfd-continue-pos start-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3256 (goto-char syntactic-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3257 (c-backward-comments) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3258 (unless (bobp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3259 (backward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3260 (c-beginning-of-current-token)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3261 (setq cfd-continue-pos (max cfd-continue-pos (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3262 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3263 ;; If we got a match it's always outside macros and comments so |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3264 ;; advance to the next token and set `cfd-token-pos'. The loop |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3265 ;; below will later go back using `cfd-continue-pos' to fix |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3266 ;; declarations inside the syntactic ws. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3267 (when (and (< cfd-match-pos cfd-limit) (< (point) syntactic-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3268 (goto-char syntactic-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3269 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3270 (and cfd-continue-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3271 (< cfd-continue-pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3272 (setq cfd-token-pos (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3273 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3274 (setq c-find-decl-match-pos (and (< cfd-match-pos start-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3275 cfd-match-pos)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3276 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3277 ;; Now loop. We already got the first match. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3278 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3279 (while (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3280 (while (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3281 (< cfd-match-pos cfd-limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3282 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3283 (or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3284 ;; Kludge to filter out matches on the "<" that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3285 ;; aren't open parens, for the sake of languages |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3286 ;; that got `c-recognize-<>-arglists' set. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3287 (and (eq (char-before cfd-match-pos) ?<) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3288 (not (c-get-char-property (1- cfd-match-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3289 'syntax-table))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3290 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3291 ;; If `cfd-continue-pos' is less or equal to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3292 ;; `cfd-token-pos', we've got a hit inside a macro |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3293 ;; that's in the syntactic whitespace before the last |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3294 ;; "real" declaration we've checked. If they're equal |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3295 ;; we've arrived at the declaration a second time, so |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3296 ;; there's nothing to do. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3297 (= cfd-continue-pos cfd-token-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3298 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3299 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3300 ;; If `cfd-continue-pos' is less than `cfd-token-pos' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3301 ;; we're still searching for declarations embedded in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3302 ;; the syntactic whitespace. In that case we need |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3303 ;; only to skip comments and not macros, since they |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3304 ;; can't be nested, and that's already been done in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3305 ;; `c-find-decl-prefix-search'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3306 (when (> cfd-continue-pos cfd-token-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3307 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3308 (setq cfd-token-pos (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3309 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3310 ;; Continue if the following token fails the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3311 ;; CFD-DECL-RE and CFD-FACE-CHECKLIST checks. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3312 (when (or (>= (point) cfd-limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3313 (not (looking-at cfd-decl-re)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3314 (and cfd-face-checklist |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3315 (not (c-got-face-at |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3316 (point) cfd-face-checklist)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3317 (goto-char cfd-continue-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3318 t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3319 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3320 (< (point) cfd-limit)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3321 (c-find-decl-prefix-search)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3322 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3323 (< (point) cfd-limit)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3324 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3325 (when (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3326 ;; Narrow to the end of the macro if we got a hit inside |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3327 ;; one, to avoid recognizing things that start inside |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3328 ;; the macro and end outside it. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3329 (when (> cfd-match-pos cfd-macro-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3330 ;; Not in the same macro as in the previous round. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3331 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3332 (goto-char cfd-match-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3333 (setq cfd-macro-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3334 (if (save-excursion (and (c-beginning-of-macro) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3335 (< (point) cfd-match-pos))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3336 (progn (c-end-of-macro) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3337 (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3338 0)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3339 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3340 (if (zerop cfd-macro-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3341 t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3342 (if (> cfd-macro-end (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3343 (progn (narrow-to-region (point-min) cfd-macro-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3344 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3345 ;; The matched token was the last thing in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3346 ;; macro, so the whole match is bogus. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3347 (setq cfd-macro-end 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3348 nil))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3349 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3350 (c-debug-put-decl-spot-faces cfd-match-pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3351 (funcall cfd-fun cfd-match-pos (/= cfd-macro-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3352 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3353 (when (/= cfd-macro-end 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3354 ;; Restore limits if we did macro narrowment above. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3355 (narrow-to-region (point-min) cfd-buffer-end))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3356 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3357 (goto-char cfd-continue-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3358 (if (= cfd-continue-pos cfd-limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3359 (setq cfd-match-pos cfd-limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3360 (c-find-decl-prefix-search))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3361 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3362 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3363 ;; A cache for found types. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3364 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3365 ;; Buffer local variable that contains an obarray with the types we've |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3366 ;; found. If a declaration is recognized somewhere we record the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3367 ;; fully qualified identifier in it to recognize it as a type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3368 ;; elsewhere in the file too. This is not accurate since we do not |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3369 ;; bother with the scoping rules of the languages, but in practice the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3370 ;; same name is seldom used as both a type and something else in a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3371 ;; file, and we only use this as a last resort in ambiguous cases (see |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3372 ;; `c-font-lock-declarations'). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3373 (defvar c-found-types nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3374 (make-variable-buffer-local 'c-found-types) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3375 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3376 (defsubst c-clear-found-types () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3377 ;; Clears `c-found-types'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3378 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3379 ;; This function does not do any hidden buffer changes. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3380 (setq c-found-types (make-vector 53 0))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3381 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3382 (defun c-add-type (from to) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3383 ;; Add the given region as a type in `c-found-types'. If the region |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3384 ;; doesn't match an existing type but there is a type which is equal |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3385 ;; to the given one except that the last character is missing, then |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3386 ;; the shorter type is removed. That's done to avoid adding all |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3387 ;; prefixes of a type as it's being entered and font locked. This |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3388 ;; doesn't cover cases like when characters are removed from a type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3389 ;; or added in the middle. We'd need the position of point when the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3390 ;; font locking is invoked to solve this well. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3391 (unless (and c-recognize-<>-arglists |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3392 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3393 (goto-char from) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3394 (c-syntactic-re-search-forward "<" to t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3395 ;; To avoid storing very long strings, do not add a type that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3396 ;; contains '<' in languages with angle bracket arglists, since |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3397 ;; the type then probably contains a C++ template spec and those |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3398 ;; can be fairly sized programs in themselves. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3399 (let ((type (c-syntactic-content from to))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3400 (unless (intern-soft type c-found-types) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3401 (unintern (substring type 0 -1) c-found-types) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3402 (intern type c-found-types))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3403 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3404 (defsubst c-check-type (from to) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3405 ;; Return non-nil if the given region contains a type in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3406 ;; `c-found-types'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3407 (intern-soft (c-syntactic-content from to) c-found-types)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3408 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3409 (defun c-list-found-types () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3410 ;; Return all the types in `c-found-types' as a sorted list of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3411 ;; strings. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3412 (let (type-list) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3413 (mapatoms (lambda (type) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3414 (setq type-list (cons (symbol-name type) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3415 type-list))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3416 c-found-types) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3417 (sort type-list 'string-lessp))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3418 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3419 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3420 ;; Handling of small scale constructs like types and names. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3421 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3422 (defun c-remove-<>-arglist-properties (from to) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3423 ;; Remove all the properties put by `c-forward-<>-arglist' in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3424 ;; specified region. Point is clobbered. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3425 (goto-char from) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3426 (while (progn (skip-chars-forward "^<>," to) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3427 (< (point) to)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3428 (if (eq (char-after) ?,) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3429 (when (eq (c-get-char-property (point) 'c-type) 'c-<>-arg-sep) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3430 (c-clear-char-property (point) 'c-type)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3431 (c-clear-char-property (point) 'syntax-table)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3432 (forward-char))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3433 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3434 ;; Dynamically bound variable that instructs `c-forward-type' to also |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3435 ;; treat possible types (i.e. those that it normally returns 'maybe or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3436 ;; 'found for) as actual types (and always return 'found for them). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3437 ;; This means that it records them in `c-record-type-identifiers' if |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3438 ;; that is set, and that it adds them to `c-found-types'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3439 (defvar c-promote-possible-types nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3440 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3441 ;; Dynamically bound variable that instructs `c-forward-<>-arglist' to |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3442 ;; not accept arglists that contain binary operators. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3443 ;; |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3444 ;; This is primarily used to handle C++ template arglists. C++ |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3445 ;; disambiguates them by checking whether the preceding name is a |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3446 ;; template or not. We can't do that, so we assume it is a template |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3447 ;; if it can be parsed as one. That usually works well since |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3448 ;; comparison expressions on the forms "a < b > c" or "a < b, c > d" |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3449 ;; in almost all cases would be pointless. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3450 ;; |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3451 ;; However, in function arglists, e.g. in "foo (a < b, c > d)", we |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3452 ;; should let the comma separate the function arguments instead. And |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3453 ;; in a context where the value of the expression is taken, e.g. in |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3454 ;; "if (a < b || c > d)", it's probably not a template. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3455 (defvar c-restricted-<>-arglists nil) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3456 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3457 ;; Dynamically bound variables that instructs `c-forward-name', |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3458 ;; `c-forward-type' and `c-forward-<>-arglist' to record the ranges of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3459 ;; all the type and reference identifiers they encounter. They will |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3460 ;; build lists on these variables where each element is a cons of the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3461 ;; buffer positions surrounding each identifier. This recording is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3462 ;; only activated when `c-record-type-identifiers' is non-nil. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3463 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3464 ;; All known types that can't be identifiers are recorded, and also |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3465 ;; other possible types if `c-promote-possible-types' is set. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3466 ;; Recording is however disabled inside angle bracket arglists that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3467 ;; are encountered inside names and other angle bracket arglists. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3468 ;; Such occurences are taken care of by `c-font-lock-<>-arglists' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3469 ;; instead. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3470 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3471 ;; Only the names in C++ template style references (e.g. "tmpl" in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3472 ;; "tmpl<a,b>::foo") are recorded as references, other references |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3473 ;; aren't handled here. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3474 (defvar c-record-type-identifiers nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3475 (defvar c-record-ref-identifiers nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3476 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3477 ;; If `c-record-type-identifiers' is set, this will receive a cons |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3478 ;; cell of the range of the last single identifier symbol stepped over |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3479 ;; by `c-forward-name' if it's successful. This is the range that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3480 ;; should be put on one of the record lists by the caller. It's |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3481 ;; assigned nil if there's no such symbol in the name. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3482 (defvar c-last-identifier-range nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3483 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3484 (defmacro c-record-type-id (range) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3485 (if (eq (car-safe range) 'cons) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3486 ;; Always true. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3487 `(setq c-record-type-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3488 (cons ,range c-record-type-identifiers)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3489 `(let ((range ,range)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3490 (if range |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3491 (setq c-record-type-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3492 (cons range c-record-type-identifiers)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3493 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3494 (defmacro c-record-ref-id (range) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3495 (if (eq (car-safe range) 'cons) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3496 ;; Always true. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3497 `(setq c-record-ref-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3498 (cons ,range c-record-ref-identifiers)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3499 `(let ((range ,range)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3500 (if range |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3501 (setq c-record-ref-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3502 (cons range c-record-ref-identifiers)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3503 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3504 ;; Dynamically bound variable that instructs `c-forward-type' to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3505 ;; record the ranges of types that only are found. Behaves otherwise |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3506 ;; like `c-record-type-identifiers'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3507 (defvar c-record-found-types nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3508 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3509 (defmacro c-forward-keyword-prefixed-id (type) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3510 ;; Used internally in `c-forward-keyword-clause' to move forward |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3511 ;; over a type (if TYPE is 'type) or a name (otherwise) which |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3512 ;; possibly is prefixed by keywords and their associated clauses. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3513 ;; Try with a type/name first to not trip up on those that begin |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3514 ;; with a keyword. Return t if a known or found type is moved |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3515 ;; over. The point is clobbered if nil is returned. If range |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3516 ;; recording is enabled, the identifier is recorded on as a type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3517 ;; if TYPE is 'type or as a reference if TYPE is 'ref. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3518 `(let (res) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3519 (while (if (setq res ,(if (eq type 'type) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3520 `(c-forward-type) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3521 `(c-forward-name))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3522 nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3523 (and (looking-at c-keywords-regexp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3524 (c-forward-keyword-clause)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3525 (when (memq res '(t known found prefix)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3526 ,(when (eq type 'ref) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3527 `(when c-record-type-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3528 (c-record-ref-id c-last-identifier-range))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3529 t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3530 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3531 (defmacro c-forward-id-comma-list (type) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3532 ;; Used internally in `c-forward-keyword-clause' to move forward |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3533 ;; over a comma separated list of types or names using |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3534 ;; `c-forward-keyword-prefixed-id'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3535 `(while (and (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3536 (setq safe-pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3537 (eq (char-after) ?,)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3538 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3539 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3540 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3541 (c-forward-keyword-prefixed-id ,type))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3542 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3543 (defun c-forward-keyword-clause () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3544 ;; The first submatch in the current match data is assumed to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3545 ;; surround a token. If it's a keyword, move over it and any |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3546 ;; following clauses associated with it, stopping at the next |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3547 ;; following token. t is returned in that case, otherwise the point |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3548 ;; stays and nil is returned. The kind of clauses that are |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3549 ;; recognized are those specified by `c-type-list-kwds', |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3550 ;; `c-ref-list-kwds', `c-colon-type-list-kwds', |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3551 ;; `c-paren-nontype-kwds', `c-paren-type-kwds', `c-<>-type-kwds', |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3552 ;; and `c-<>-arglist-kwds'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3553 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3554 (let ((kwd-sym (c-keyword-sym (match-string 1))) safe-pos pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3555 (when kwd-sym |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3556 (goto-char (match-end 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3557 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3558 (setq safe-pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3559 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3560 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3561 ((and (c-keyword-member kwd-sym 'c-type-list-kwds) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3562 (c-forward-keyword-prefixed-id type)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3563 ;; There's a type directly after a keyword in `c-type-list-kwds'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3564 (c-forward-id-comma-list type)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3565 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3566 ((and (c-keyword-member kwd-sym 'c-ref-list-kwds) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3567 (c-forward-keyword-prefixed-id ref)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3568 ;; There's a name directly after a keyword in `c-ref-list-kwds'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3569 (c-forward-id-comma-list ref)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3570 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3571 ((and (c-keyword-member kwd-sym 'c-paren-any-kwds) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3572 (eq (char-after) ?\()) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3573 ;; There's an open paren after a keyword in `c-paren-any-kwds'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3574 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3575 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3576 (when (and (setq pos (c-up-list-forward)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3577 (eq (char-before pos) ?\))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3578 (when (and c-record-type-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3579 (c-keyword-member kwd-sym 'c-paren-type-kwds)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3580 ;; Use `c-forward-type' on every identifier we can find |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3581 ;; inside the paren, to record the types. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3582 (while (c-syntactic-re-search-forward c-symbol-start pos t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3583 (goto-char (match-beginning 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3584 (unless (c-forward-type) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3585 (looking-at c-symbol-key) ; Always matches. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3586 (goto-char (match-end 0))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3587 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3588 (goto-char pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3589 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3590 (setq safe-pos (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3591 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3592 ((and (c-keyword-member kwd-sym 'c-<>-sexp-kwds) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3593 (eq (char-after) ?<) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3594 (c-forward-<>-arglist (c-keyword-member kwd-sym 'c-<>-type-kwds) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3595 (or c-record-type-identifiers |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3596 c-restricted-<>-arglists))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3597 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3598 (setq safe-pos (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3599 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3600 ((and (c-keyword-member kwd-sym 'c-nonsymbol-sexp-kwds) |
52605
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
3601 (not (looking-at c-symbol-start)) |
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
3602 (c-safe (c-forward-sexp) t)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3603 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3604 (setq safe-pos (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3605 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3606 (when (and (c-keyword-member kwd-sym 'c-colon-type-list-kwds) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3607 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3608 ;; If a keyword matched both one of the types above and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3609 ;; this one, we match `c-colon-type-list-re' after the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3610 ;; clause matched above. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3611 (goto-char safe-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3612 (looking-at c-colon-type-list-re)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3613 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3614 (goto-char (match-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3615 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3616 (c-forward-keyword-prefixed-id type))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3617 ;; There's a type after the `c-colon-type-list-re' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3618 ;; match after a keyword in `c-colon-type-list-kwds'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3619 (c-forward-id-comma-list type)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3620 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3621 (goto-char safe-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3622 t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3623 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3624 (defun c-forward-<>-arglist (all-types reparse) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3625 ;; The point is assumed to be at a '<'. Try to treat it as the open |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3626 ;; paren of an angle bracket arglist and move forward to the the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3627 ;; corresponding '>'. If successful, the point is left after the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3628 ;; '>' and t is returned, otherwise the point isn't moved and nil is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3629 ;; returned. If ALL-TYPES is t then all encountered arguments in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3630 ;; the arglist that might be types are treated as found types. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3631 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3632 ;; The surrounding '<' and '>' are given syntax-table properties to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3633 ;; make them behave like parentheses. Each argument separating ',' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3634 ;; is also set to `c-<>-arg-sep' in the `c-type' property. These |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3635 ;; properties are also cleared in a relevant region forward from the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3636 ;; point if they seems to be set and it turns out to not be an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3637 ;; arglist. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3638 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3639 ;; If the arglist has been successfully parsed before then paren |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3640 ;; syntax properties will be exploited to quickly jump to the end, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3641 ;; but that can be disabled by setting REPARSE to t. That is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3642 ;; necessary if the various side effects, e.g. recording of type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3643 ;; ranges, are important. Setting REPARSE to t only applies |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3644 ;; recursively to nested angle bracket arglists if |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3645 ;; `c-restricted-<>-arglists' is set. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3646 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3647 (let ((start (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3648 ;; If `c-record-type-identifiers' is set then activate |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3649 ;; recording of any found types that constitute an argument in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3650 ;; the arglist. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3651 (c-record-found-types (if c-record-type-identifiers t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3652 (if (catch 'angle-bracket-arglist-escape |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3653 (setq c-record-found-types |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3654 (c-forward-<>-arglist-recur all-types reparse))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3655 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3656 (when (consp c-record-found-types) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3657 (setq c-record-type-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3658 ;; `nconc' doesn't mind that the tail of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3659 ;; `c-record-found-types' is t. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3660 (nconc c-record-found-types c-record-type-identifiers))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3661 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3662 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3663 (goto-char start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3664 nil))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3665 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3666 (defun c-forward-<>-arglist-recur (all-types reparse) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3667 ;; Recursive part of `c-forward-<>-arglist'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3668 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3669 (let ((start (point)) res pos tmp |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3670 ;; Cover this so that any recorded found type ranges are |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3671 ;; automatically lost if it turns out to not be an angle |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3672 ;; bracket arglist. It's propagated through the return value |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3673 ;; on successful completion. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3674 (c-record-found-types c-record-found-types) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3675 ;; List that collects the positions after the argument |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3676 ;; separating ',' in the arglist. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3677 arg-start-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3678 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3679 ;; If the '<' has paren open syntax then we've marked it as an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3680 ;; angle bracket arglist before, so try to skip to the end and see |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3681 ;; that the close paren matches. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3682 (if (and (c-get-char-property (point) 'syntax-table) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3683 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3684 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3685 (if (and (not (looking-at c-<-op-cont-regexp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3686 (if (c-parse-sexp-lookup-properties) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3687 (c-go-up-list-forward) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3688 (catch 'at-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3689 (let ((depth 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3690 (while (c-syntactic-re-search-forward |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3691 "[<>]" nil t t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3692 (when (c-get-char-property (1- (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3693 'syntax-table) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3694 (if (eq (char-before) ?<) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3695 (setq depth (1+ depth)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3696 (setq depth (1- depth)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3697 (when (= depth 0) (throw 'at-end t))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3698 nil))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3699 (not (looking-at c->-op-cont-regexp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3700 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3701 (backward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3702 (= (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3703 (progn (c-beginning-of-current-token) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3704 (point))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3705 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3706 ;; Got an arglist that appears to be valid. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3707 (if reparse |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3708 ;; Reparsing is requested, so zap the properties in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3709 ;; region and go on to redo it. It's done here to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3710 ;; avoid leaving it behind if we exit through |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3711 ;; `angle-bracket-arglist-escape' below. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3712 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3713 (c-remove-<>-arglist-properties start (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3714 (goto-char start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3715 nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3716 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3717 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3718 ;; Got unmatched paren brackets or either paren was |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3719 ;; actually some other token. Recover by clearing the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3720 ;; syntax properties on all the '<' and '>' in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3721 ;; range where we'll search for the arglist below. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3722 (goto-char start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3723 (while (progn (skip-chars-forward "^<>,;{}") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3724 (looking-at "[<>,]")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3725 (if (eq (char-after) ?,) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3726 (when (eq (c-get-char-property (point) 'c-type) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3727 'c-<>-arg-sep) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3728 (c-clear-char-property (point) 'c-type)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3729 (c-clear-char-property (point) 'syntax-table)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3730 (forward-char)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3731 (goto-char start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3732 nil))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3733 t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3734 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3735 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3736 (unless (looking-at c-<-op-cont-regexp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3737 (while (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3738 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3739 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3740 (when c-record-type-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3741 (if all-types |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3742 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3743 ;; All encountered identifiers are types, so set the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3744 ;; promote flag and parse the type. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3745 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3746 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3747 (when (looking-at c-identifier-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3748 (let ((c-promote-possible-types t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3749 (c-forward-type)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3750 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3751 ;; Check if this arglist argument is a sole type. If |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3752 ;; it's known then it's recorded in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3753 ;; `c-record-type-identifiers'. If it only is found |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3754 ;; then it's recorded in `c-record-found-types' which we |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3755 ;; might roll back if it turns out that this isn't an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3756 ;; angle bracket arglist afterall. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3757 (when (memq (char-before) '(?, ?<)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3758 (let ((orig-record-found-types c-record-found-types)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3759 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3760 (and (memq (c-forward-type) '(known found)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3761 (not (looking-at "[,>]")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3762 ;; A found type was recorded but it's not the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3763 ;; only thing in the arglist argument, so reset |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3764 ;; `c-record-found-types'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3765 (setq c-record-found-types |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3766 orig-record-found-types)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3767 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3768 (setq pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3769 (or (when (eq (char-after) ?>) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3770 ;; Must check for '>' at the very start separately, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3771 ;; since the regexp below has to avoid ">>" without |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3772 ;; using \\=. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3773 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3774 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3775 |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3776 ;; Note: These regexps exploit the match order in \| so |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3777 ;; that "<>" is matched by "<" rather than "[^>:-]>". |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3778 (c-syntactic-re-search-forward |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3779 (if c-restricted-<>-arglists |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3780 ;; Stop on ',', '|', '&', '+' and '-' to catch |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3781 ;; common binary operators that could be between |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3782 ;; two comparison expressions "a<b" and "c>d". |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3783 "[<;{},|&+-]\\|\\([^>:-]>\\)" |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3784 ;; Otherwise we still stop on ',' to find the |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3785 ;; argument start positions. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3786 "[<;{},]\\|\\([^>:-]>\\)") |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3787 nil 'move t t 1) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3788 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3789 ;; If the arglist starter has lost its open paren |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3790 ;; syntax but not the closer, we won't find the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3791 ;; closer above since we only search in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3792 ;; balanced sexp. In that case we stop just short |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3793 ;; of it so check if the following char is the closer. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3794 (when (eq (char-after) ?>) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3795 ;; Remove its syntax so that we don't enter the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3796 ;; recovery code below. That's not necessary |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3797 ;; since there's no real reason to suspect that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3798 ;; things inside the arglist are unbalanced. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3799 (c-clear-char-property (point) 'syntax-table) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3800 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3801 t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3802 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3803 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3804 ((eq (char-before) ?>) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3805 ;; Either an operator starting with '>' or the end of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3806 ;; the angle bracket arglist. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3807 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3808 (if (and (/= (1- (point)) pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3809 (c-get-char-property (1- (point)) 'syntax-table) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3810 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3811 (c-clear-char-property (1- (point)) 'syntax-table) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3812 (c-parse-sexp-lookup-properties))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3813 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3814 ;; We've skipped past a list that ended with '>'. It |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3815 ;; must be unbalanced since nested arglists are handled |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3816 ;; in the case below. Recover by removing all paren |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3817 ;; properties on '<' and '>' in the searched region and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3818 ;; redo the search. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3819 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3820 (c-remove-<>-arglist-properties pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3821 (goto-char pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3822 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3823 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3824 (if (looking-at c->-op-cont-regexp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3825 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3826 (when (text-property-not-all |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3827 (1- (point)) (match-end 0) 'syntax-table nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3828 (c-remove-<>-arglist-properties (1- (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3829 (match-end 0))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3830 (goto-char (match-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3831 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3832 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3833 ;; The angle bracket arglist is finished. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3834 (while arg-start-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3835 (c-put-char-property (1- (car arg-start-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3836 'c-type 'c-<>-arg-sep) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3837 (setq arg-start-pos (cdr arg-start-pos))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3838 (c-mark-<-as-paren start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3839 (c-mark->-as-paren (1- (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3840 (setq res t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3841 nil))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3842 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3843 ((eq (char-before) ?<) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3844 ;; Either an operator starting with '<' or a nested arglist. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3845 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3846 (setq pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3847 (let (id-start id-end subres keyword-match) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3848 (if (if (looking-at c-<-op-cont-regexp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3849 (setq tmp (match-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3850 (setq tmp pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3851 (backward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3852 (not |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3853 (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3854 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3855 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3856 ;; There's always an identifier before a angle |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3857 ;; bracket arglist, or a keyword in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3858 ;; `c-<>-type-kwds' or `c-<>-arglist-kwds'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3859 (c-backward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3860 (setq id-end (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3861 (c-simple-skip-symbol-backward) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3862 (when (or (setq keyword-match |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3863 (looking-at c-opt-<>-sexp-key)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3864 (not (looking-at c-keywords-regexp))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3865 (setq id-start (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3866 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3867 (setq subres |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3868 (let ((c-record-type-identifiers nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3869 (c-record-found-types nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3870 (c-forward-<>-arglist-recur |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3871 (and keyword-match |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3872 (c-keyword-member |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3873 (c-keyword-sym (match-string 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3874 'c-<>-type-kwds)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3875 (and reparse |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3876 c-restricted-<>-arglists)))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3877 ))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3878 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3879 ;; It was not an angle bracket arglist. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3880 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3881 (when (text-property-not-all |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3882 (1- pos) tmp 'syntax-table nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3883 (if (c-parse-sexp-lookup-properties) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3884 ;; Got an invalid open paren syntax on this |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3885 ;; '<'. We'll probably get an unbalanced '>' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3886 ;; further ahead if we just remove the syntax |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3887 ;; here, so recover by removing all paren |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3888 ;; properties up to and including the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3889 ;; balancing close paren. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3890 (parse-partial-sexp pos (point-max) -1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3891 (goto-char tmp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3892 (c-remove-<>-arglist-properties pos (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3893 (goto-char tmp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3894 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3895 ;; It was an angle bracket arglist. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3896 (setq c-record-found-types subres) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3897 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3898 ;; Record the identifier before the template as a type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3899 ;; or reference depending on whether the arglist is last |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3900 ;; in a qualified identifier. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3901 (when (and c-record-type-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3902 (not keyword-match)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3903 (if (and c-opt-identifier-concat-key |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3904 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3905 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3906 (looking-at c-opt-identifier-concat-key))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3907 (c-record-ref-id (cons id-start id-end)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3908 (c-record-type-id (cons id-start id-end)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3909 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3910 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3911 ((and (eq (char-before) ?,) |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
3912 (not c-restricted-<>-arglists)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3913 ;; Just another argument. Record the position. The |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3914 ;; type check stuff that made us stop at it is at |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3915 ;; the top of the loop. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3916 (setq arg-start-pos (cons (point) arg-start-pos))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3917 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3918 (t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3919 ;; Got a character that can't be in an angle bracket |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3920 ;; arglist argument. Abort using `throw', since |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3921 ;; it's useless to try to find a surrounding arglist |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3922 ;; if we're nested. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3923 (throw 'angle-bracket-arglist-escape nil)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3924 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3925 (if res |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3926 (or c-record-found-types t))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3927 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3928 (defun c-forward-name () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3929 ;; Move forward over a complete name if at the beginning of one, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3930 ;; stopping at the next following token. If the point is not at |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3931 ;; something that are recognized as name then it stays put. A name |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3932 ;; could be something as simple as "foo" in C or something as |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3933 ;; complex as "X<Y<class A<int>::B, BIT_MAX >> b>, ::operator<> :: |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3934 ;; Z<(a>b)> :: operator const X<&foo>::T Q::G<unsigned short |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3935 ;; int>::*volatile const" in C++ (this function is actually little |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3936 ;; more than a `looking-at' call in all modes except those that, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3937 ;; like C++, have `c-recognize-<>-arglists' set). Return nil if no |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3938 ;; name is found, 'template if it's an identifier ending with an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3939 ;; angle bracket arglist, 'operator of it's an operator identifier, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3940 ;; or t if it's some other kind of name. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3941 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3942 (let ((pos (point)) res id-start id-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3943 ;; Turn off `c-promote-possible-types' here since we might |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3944 ;; call `c-forward-<>-arglist' and we don't want it to promote |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3945 ;; every suspect thing in the arglist to a type. We're |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3946 ;; typically called from `c-forward-type' in this case, and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3947 ;; the caller only wants the top level type that it finds to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3948 ;; be promoted. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3949 c-promote-possible-types) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3950 (while |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3951 (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3952 (looking-at c-identifier-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3953 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3954 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3955 ;; Check for keyword. We go to the last symbol in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3956 ;; `c-identifier-key' first. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3957 (if (eq c-identifier-key c-symbol-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3958 (setq id-start (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3959 id-end (match-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3960 (goto-char (setq id-end (match-end 0))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3961 (c-simple-skip-symbol-backward) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3962 (setq id-start (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3963 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3964 (if (looking-at c-keywords-regexp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3965 (when (and (c-major-mode-is 'c++-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3966 (looking-at |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3967 (cc-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3968 (concat "\\(operator\\|\\(template\\)\\)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3969 "\\(" (c-lang-const c-nonsymbol-key c++) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3970 "\\|$\\)"))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3971 (if (match-beginning 2) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3972 ;; "template" is only valid inside an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3973 ;; identifier if preceded by "::". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3974 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3975 (c-backward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3976 (and (c-safe (backward-char 2) t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3977 (looking-at "::"))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3978 t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3979 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3980 ;; Handle a C++ operator or template identifier. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3981 (goto-char id-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3982 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3983 (cond ((eq (char-before id-end) ?e) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3984 ;; Got "... ::template". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3985 (let ((subres (c-forward-name))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3986 (when subres |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3987 (setq pos (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3988 res subres)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3989 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3990 ((looking-at c-identifier-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3991 ;; Got a cast operator. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3992 (when (c-forward-type) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3993 (setq pos (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3994 res 'operator) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3995 ;; Now we should match a sequence of either |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3996 ;; '*', '&' or a name followed by ":: *", |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3997 ;; where each can be followed by a sequence |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3998 ;; of `c-opt-type-modifier-key'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
3999 (while (cond ((looking-at "[*&]") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4000 (goto-char (match-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4001 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4002 ((looking-at c-identifier-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4003 (and (c-forward-name) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4004 (looking-at "::") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4005 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4006 (goto-char (match-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4007 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4008 (eq (char-after) ?*)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4009 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4010 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4011 t)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4012 (while (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4013 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4014 (setq pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4015 (looking-at c-opt-type-modifier-key)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4016 (goto-char (match-end 1)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4017 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4018 ((looking-at c-overloadable-operators-regexp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4019 ;; Got some other operator. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4020 (when c-record-type-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4021 (setq c-last-identifier-range |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4022 (cons (point) (match-end 0)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4023 (goto-char (match-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4024 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4025 (setq pos (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4026 res 'operator))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4027 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4028 nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4029 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4030 (when c-record-type-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4031 (setq c-last-identifier-range |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4032 (cons id-start id-end))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4033 (goto-char id-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4034 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4035 (setq pos (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4036 res t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4037 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4038 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4039 (goto-char pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4040 (when (or c-opt-identifier-concat-key |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4041 c-recognize-<>-arglists) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4042 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4043 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4044 ((and c-opt-identifier-concat-key |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4045 (looking-at c-opt-identifier-concat-key)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4046 ;; Got a concatenated identifier. This handles the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4047 ;; cases with tricky syntactic whitespace that aren't |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4048 ;; covered in `c-identifier-key'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4049 (goto-char (match-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4050 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4051 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4052 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4053 ((and c-recognize-<>-arglists |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4054 (eq (char-after) ?<)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4055 ;; Maybe an angle bracket arglist. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4056 (when (let ((c-record-type-identifiers nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4057 (c-record-found-types nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4058 (c-forward-<>-arglist |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4059 nil c-restricted-<>-arglists)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4060 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4061 (setq pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4062 (if (and c-opt-identifier-concat-key |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4063 (looking-at c-opt-identifier-concat-key)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4064 ;; Continue if there's an identifier concatenation |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4065 ;; operator after the template argument. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4066 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4067 (when c-record-type-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4068 (c-record-ref-id (cons id-start id-end)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4069 (setq c-last-identifier-range nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4070 (forward-char 2) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4071 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4072 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4073 ;; `c-add-type' isn't called here since we don't |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4074 ;; want to add types containing angle bracket |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4075 ;; arglists. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4076 (when c-record-type-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4077 (c-record-type-id (cons id-start id-end)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4078 (setq c-last-identifier-range nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4079 (setq res 'template) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4080 nil))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4081 ))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4082 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4083 (goto-char pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4084 res)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4085 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4086 (defun c-forward-type () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4087 ;; Move forward over a type spec if at the beginning of one, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4088 ;; stopping at the next following token. Return t if it's a known |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
4089 ;; type that can't be a name or other expression, 'known if it's an |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
4090 ;; otherwise known type (according to `*-font-lock-extra-types'), |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
4091 ;; 'prefix if it's a known prefix of a type, 'found if it's a type |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
4092 ;; that matches one in `c-found-types', 'maybe if it's an identfier |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
4093 ;; that might be a type, or nil if it can't be a type (the point |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
4094 ;; isn't moved then). The point is assumed to be at the beginning |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
4095 ;; of a token. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4096 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4097 ;; Note that this function doesn't skip past the brace definition |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4098 ;; that might be considered part of the type, e.g. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4099 ;; "enum {a, b, c} foo". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4100 (let ((start (point)) pos res res2 id-start id-end id-range) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4101 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4102 ;; Skip leading type modifiers. If any are found we know it's a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4103 ;; prefix of a type. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4104 (when c-opt-type-modifier-key |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4105 (while (looking-at c-opt-type-modifier-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4106 (goto-char (match-end 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4107 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4108 (setq res 'prefix))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4109 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4110 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4111 ((looking-at c-type-prefix-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4112 ;; Looking at a keyword that prefixes a type identifier, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4113 ;; e.g. "class". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4114 (goto-char (match-end 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4115 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4116 (setq pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4117 (if (memq (setq res2 (c-forward-name)) '(t template)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4118 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4119 (when (eq res2 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4120 ;; In many languages the name can be used without the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4121 ;; prefix, so we add it to `c-found-types'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4122 (c-add-type pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4123 (when c-record-type-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4124 (c-record-type-id c-last-identifier-range))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4125 (setq res t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4126 ;; Invalid syntax. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4127 (goto-char start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4128 (setq res nil))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4129 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4130 ((progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4131 (setq pos nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4132 (if (looking-at c-identifier-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4133 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4134 (setq id-start (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4135 res2 (c-forward-name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4136 (when res2 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4137 (setq id-end (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4138 id-range c-last-identifier-range)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4139 (and (cond ((looking-at c-primitive-type-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4140 (setq res t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4141 ((c-with-syntax-table c-identifier-syntax-table |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4142 (looking-at c-known-type-key)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4143 (setq res 'known))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4144 (or (not id-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4145 (>= (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4146 (save-match-data |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4147 (goto-char (match-end 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4148 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4149 (setq pos (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4150 id-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4151 (setq res nil)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4152 ;; Looking at a primitive or known type identifier. We've |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4153 ;; checked for a name first so that we don't go here if the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4154 ;; known type match only is a prefix of another name. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4155 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4156 (setq id-end (match-end 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4157 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4158 (when (and c-record-type-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4159 (or c-promote-possible-types (eq res t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4160 (c-record-type-id (cons (match-beginning 1) (match-end 1)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4161 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4162 (if (and c-opt-type-component-key |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4163 (save-match-data |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4164 (looking-at c-opt-type-component-key))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4165 ;; There might be more keywords for the type. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4166 (let (safe-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4167 (c-forward-keyword-clause) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4168 (while (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4169 (setq safe-pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4170 (looking-at c-opt-type-component-key)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4171 (when (and c-record-type-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4172 (looking-at c-primitive-type-key)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4173 (c-record-type-id (cons (match-beginning 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4174 (match-end 1)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4175 (c-forward-keyword-clause)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4176 (if (looking-at c-primitive-type-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4177 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4178 (when c-record-type-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4179 (c-record-type-id (cons (match-beginning 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4180 (match-end 1)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4181 (c-forward-keyword-clause) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4182 (setq res t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4183 (goto-char safe-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4184 (setq res 'prefix))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4185 (unless (save-match-data (c-forward-keyword-clause)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4186 (if pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4187 (goto-char pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4188 (goto-char (match-end 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4189 (c-forward-syntactic-ws))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4190 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4191 (res2 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4192 (cond ((eq res2 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4193 ;; A normal identifier. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4194 (goto-char id-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4195 (if (or res c-promote-possible-types) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4196 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4197 (c-add-type id-start id-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4198 (when c-record-type-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4199 (c-record-type-id id-range)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4200 (unless res |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4201 (setq res 'found))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4202 (setq res (if (c-check-type id-start id-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4203 ;; It's an identifier that has been used as |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4204 ;; a type somewhere else. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4205 'found |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4206 ;; It's an identifier that might be a type. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4207 'maybe)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4208 ((eq res2 'template) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4209 ;; A template is a type. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4210 (goto-char id-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4211 (setq res t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4212 (t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4213 ;; Otherwise it's an operator identifier, which is not a type. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4214 (goto-char start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4215 (setq res nil))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4216 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4217 (when res |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4218 ;; Skip trailing type modifiers. If any are found we know it's |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4219 ;; a type. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4220 (when c-opt-type-modifier-key |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4221 (while (looking-at c-opt-type-modifier-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4222 (goto-char (match-end 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4223 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4224 (setq res t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4225 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4226 ;; Step over any type suffix operator. Do not let the existence |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4227 ;; of these alter the classification of the found type, since |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4228 ;; these operators typically are allowed in normal expressions |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4229 ;; too. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4230 (when c-opt-type-suffix-key |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4231 (while (looking-at c-opt-type-suffix-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4232 (goto-char (match-end 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4233 (c-forward-syntactic-ws))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4234 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4235 (when c-opt-type-concat-key |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4236 ;; Look for a trailing operator that concatenate the type with |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4237 ;; a following one, and if so step past that one through a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4238 ;; recursive call. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4239 (setq pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4240 (let* ((c-promote-possible-types (or (memq res '(t known)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4241 c-promote-possible-types)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4242 ;; If we can't promote then set `c-record-found-types' so that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4243 ;; we can merge in the types from the second part afterwards if |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4244 ;; it turns out to be a known type there. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4245 (c-record-found-types (and c-record-type-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4246 (not c-promote-possible-types)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4247 (if (and (looking-at c-opt-type-concat-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4248 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4249 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4250 (goto-char (match-end 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4251 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4252 (setq res2 (c-forward-type)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4253 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4254 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4255 ;; If either operand certainly is a type then both are, but we |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4256 ;; don't let the existence of the operator itself promote two |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4257 ;; uncertain types to a certain one. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4258 (cond ((eq res t)) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
4259 ((eq res2 t) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4260 (c-add-type id-start id-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4261 (when c-record-type-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4262 (c-record-type-id id-range)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4263 (setq res t)) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
4264 ((eq res 'known)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
4265 ((eq res2 'known) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
4266 (setq res 'known)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4267 ((eq res 'found)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4268 ((eq res2 'found) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4269 (setq res 'found)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4270 (t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4271 (setq res 'maybe))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4272 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4273 (when (and (eq res t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4274 (consp c-record-found-types)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4275 ;; Merge in the ranges of any types found by the second |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4276 ;; `c-forward-type'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4277 (setq c-record-type-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4278 ;; `nconc' doesn't mind that the tail of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4279 ;; `c-record-found-types' is t. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4280 (nconc c-record-found-types |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4281 c-record-type-identifiers)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4282 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4283 (goto-char pos)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4284 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4285 (when (and c-record-found-types (memq res '(known found)) id-range) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4286 (setq c-record-found-types |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4287 (cons id-range c-record-found-types)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4288 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4289 ;;(message "c-forward-type %s -> %s: %s" start (point) res) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4290 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4291 res)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4292 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4293 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4294 ;; Handling of large scale constructs like statements and declarations. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4295 |
18720 | 4296 (defun c-beginning-of-inheritance-list (&optional lim) |
4297 ;; Go to the first non-whitespace after the colon that starts a | |
4298 ;; multiple inheritance introduction. Optional LIM is the farthest | |
4299 ;; back we should search. | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4300 (let* ((lim (or lim (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4301 (c-beginning-of-syntax) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4302 (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
|
4303 (c-with-syntax-table c++-template-syntax-table |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4304 (c-backward-token-2 0 t lim) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4305 (while (and (or (looking-at c-symbol-start) |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4306 (looking-at "[<,]\\|::")) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4307 (zerop (c-backward-token-2 1 t lim)))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4308 (skip-chars-forward "^:")))) |
18720 | 4309 |
4310 (defun c-in-method-def-p () | |
4311 ;; Return nil if we aren't in a method definition, otherwise the | |
4312 ;; position of the initial [+-]. | |
4313 (save-excursion | |
4314 (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
|
4315 (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
|
4316 (looking-at c-opt-method-key) |
18720 | 4317 (point)) |
4318 )) | |
4319 | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4320 ;; 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
|
4321 (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
|
4322 ;; 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
|
4323 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4324 ;; 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
|
4325 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4326 ;; 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
|
4327 ;; 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
|
4328 ;; 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
|
4329 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4330 (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
|
4331 (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
|
4332 (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
|
4333 (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
|
4334 (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
|
4335 (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
|
4336 |
24335
0c4688f9a396
Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents:
24282
diff
changeset
|
4337 (defun c-at-toplevel-p () |
0c4688f9a396
Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents:
24282
diff
changeset
|
4338 "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
|
4339 Being at the top-level means that point is either outside any |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4340 enclosing block (such function definition), or only inside a class, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4341 namespace or other block that contains another declaration level. |
24335
0c4688f9a396
Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents:
24282
diff
changeset
|
4342 |
0c4688f9a396
Added c-at-toplevel-p for font-lock.el.
Simon Marshall <simon@gnu.org>
parents:
24282
diff
changeset
|
4343 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
|
4344 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
|
4345 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
|
4346 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
|
4347 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
|
4348 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
|
4349 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
|
4350 (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
|
4351 (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
|
4352 (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
|
4353 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4354 (defun c-just-after-func-arglist-p (&optional lim) |
52605
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
4355 ;; Return non-nil if we are between a function's argument list closing |
18720 | 4356 ;; paren and its opening brace. Note that the list close brace |
4357 ;; could be followed by a "const" specifier or a member init hanging | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4358 ;; colon. LIM is used as bound for some backward buffer searches; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4359 ;; the search might continue past it. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4360 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4361 ;; 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
|
4362 ;; in the situations where `c-guess-basic-syntax' uses it. |
18720 | 4363 (save-excursion |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4364 (if (c-mode-is-new-awk-p) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4365 (c-awk-backward-syntactic-ws lim) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4366 (c-backward-syntactic-ws lim)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4367 (let ((checkpoint (point))) |
18720 | 4368 ;; could be looking at const specifier |
4369 (if (and (eq (char-before) ?t) | |
4370 (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
|
4371 (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
|
4372 (c-backward-syntactic-ws lim) |
18720 | 4373 ;; otherwise, we could be looking at a hanging member init |
4374 ;; colon | |
4375 (goto-char checkpoint) | |
52339
721da86ff178
(c-just-after-func-arglist-p): Safeguard against unbalanced sexps.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52107
diff
changeset
|
4376 (while (and |
721da86ff178
(c-just-after-func-arglist-p): Safeguard against unbalanced sexps.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52107
diff
changeset
|
4377 (eq (char-before) ?,) |
721da86ff178
(c-just-after-func-arglist-p): Safeguard against unbalanced sexps.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52107
diff
changeset
|
4378 ;; this will catch member inits with multiple |
721da86ff178
(c-just-after-func-arglist-p): Safeguard against unbalanced sexps.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52107
diff
changeset
|
4379 ;; line arglists |
721da86ff178
(c-just-after-func-arglist-p): Safeguard against unbalanced sexps.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52107
diff
changeset
|
4380 (progn |
721da86ff178
(c-just-after-func-arglist-p): Safeguard against unbalanced sexps.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52107
diff
changeset
|
4381 (forward-char -1) |
721da86ff178
(c-just-after-func-arglist-p): Safeguard against unbalanced sexps.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52107
diff
changeset
|
4382 (c-backward-syntactic-ws (c-point 'bol)) |
721da86ff178
(c-just-after-func-arglist-p): Safeguard against unbalanced sexps.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52107
diff
changeset
|
4383 (c-safe (c-backward-sexp 1) t)) |
721da86ff178
(c-just-after-func-arglist-p): Safeguard against unbalanced sexps.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52107
diff
changeset
|
4384 (or (not (looking-at "\\s\(")) |
721da86ff178
(c-just-after-func-arglist-p): Safeguard against unbalanced sexps.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52107
diff
changeset
|
4385 (c-safe (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
|
4386 (c-backward-syntactic-ws lim)) |
18720 | 4387 (if (and (eq (char-before) ?:) |
4388 (progn | |
4389 (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
|
4390 (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
|
4391 (looking-at "\\([ \t\n]\\|\\\\\n\\)*:\\([^:]+\\|$\\)"))) |
18720 | 4392 nil |
4393 (goto-char checkpoint)) | |
4394 ) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4395 (setq checkpoint (point)) |
18720 | 4396 (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
|
4397 ;; 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
|
4398 ;; 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
|
4399 ;; 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
|
4400 (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
|
4401 (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
|
4402 (< (point) checkpoint))) |
52605
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
4403 ;; Check if we are looking at an ObjC method def or a class |
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
4404 ;; category. |
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
4405 (not (and c-opt-method-key |
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
4406 (progn |
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
4407 (goto-char checkpoint) |
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
4408 (c-safe (c-backward-sexp) t)) |
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
4409 (progn |
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
4410 (c-backward-syntactic-ws lim) |
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
4411 (or (memq (char-before) '(?- ?+)) |
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
4412 (and (c-safe (c-forward-sexp -2) t) |
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
4413 (looking-at c-class-key)))))) |
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
4414 ;; Pike has compound types that include parens, |
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
4415 ;; e.g. "array(string)". Check that we aren't after one. |
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
4416 (not (and (c-major-mode-is 'pike-mode) |
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
4417 (progn |
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
4418 (goto-char checkpoint) |
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
4419 (c-safe (c-backward-sexp 2) t)) |
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
4420 (looking-at c-primitive-type-key))) |
50c6e94a91cb
(c-parse-state): Fixed bug that could cause errors when the state
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
4421 )))) |
18720 | 4422 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4423 (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
|
4424 ;; 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
|
4425 ;; 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
|
4426 ;; `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
|
4427 ;; 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
|
4428 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4429 ;; Note: A declaration level context is assumed; the test can return |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4430 ;; false positives for statements. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4431 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4432 (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
|
4433 (save-restriction |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4434 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4435 ;; 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
|
4436 ;; 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
|
4437 ;; 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
|
4438 ;; 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
|
4439 ;; in. |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4440 (if lim (narrow-to-region lim (c-point 'eol))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4441 (let ((outside-macro (not (c-query-macro-start))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4442 paren-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4443 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4444 (catch 'done |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4445 (while (if (and (setq paren-end (c-down-list-backward (point))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4446 (eq (char-after paren-end) ?\))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4447 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4448 (goto-char (1+ paren-end)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4449 (if outside-macro |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4450 (c-beginning-of-macro))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4451 (throw 'done nil)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4452 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4453 (and (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
|
4454 (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
|
4455 (looking-at "\\w\\|\\s_")) |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4456 |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4457 (save-excursion |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4458 ;; The function header in a K&R declaration should only |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4459 ;; contain identifiers separated by comma. It should |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4460 ;; also contain at least one identifier since there |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4461 ;; wouldn't be anything to declare in the K&R region |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4462 ;; otherwise. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4463 (when (c-go-up-list-backward paren-end) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4464 (forward-char) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4465 (catch 'knr-ok |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4466 (while t |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4467 (c-forward-syntactic-ws) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4468 (if (or (looking-at c-known-type-key) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4469 (looking-at c-keywords-regexp)) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4470 (throw 'knr-ok nil)) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4471 (c-forward-token-2) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4472 (if (eq (char-after) ?,) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4473 (forward-char) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4474 (throw 'knr-ok (and (eq (char-after) ?\)) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4475 (= (point) paren-end)))))))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4476 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4477 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4478 ;; If it's a K&R declaration then we're now at the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4479 ;; beginning of the function arglist. Check that there |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4480 ;; isn't a '=' before it in this statement since that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4481 ;; means it some kind of initialization instead. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4482 (c-syntactic-skip-backward "^;=}{") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4483 (not (eq (char-before) ?=))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4484 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4485 (point)))))) |
18720 | 4486 |
4487 (defun c-skip-conditional () | |
4488 ;; skip forward over conditional at point, including any predicate | |
4489 ;; statements in parentheses. No error checking is performed. | |
24282 | 4490 (c-forward-sexp (cond |
4491 ;; 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
|
4492 ((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
|
4493 "\\([ \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
|
4494 "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
|
4495 3) |
24282 | 4496 ;; 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
|
4497 ((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
|
4498 "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
|
4499 "\\)\\>\\([^_]\\|$\\)")) |
36920 | 4500 1) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
4501 ;; for, if, while, switch, catch, synchronized, foreach |
24282 | 4502 (t 2)))) |
18720 | 4503 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4504 (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
|
4505 ;; 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
|
4506 ;; 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
|
4507 (save-excursion |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4508 (and (zerop (c-backward-token-2 1 t lim)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4509 (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
|
4510 (and (eq (char-after) ?\() |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4511 (zerop (c-backward-token-2 1 t lim)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4512 (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
|
4513 (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
|
4514 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4515 (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
|
4516 ;; 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
|
4517 ;; 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
|
4518 ;; 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
|
4519 ;; 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
|
4520 ;; 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
|
4521 (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
|
4522 (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
|
4523 (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
|
4524 (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
|
4525 |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4526 (defsubst c-backward-to-decl-anchor (&optional lim) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4527 ;; 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
|
4528 ;; 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
|
4529 ;; 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
|
4530 (unless (= (point) (c-point 'boi)) |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4531 (c-beginning-of-statement-1 lim))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4532 |
52107
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4533 (defun c-search-decl-header-end () |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4534 ;; 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
|
4535 ;; 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
|
4536 ;; 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
|
4537 ;; 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
|
4538 ;; (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
|
4539 ;; _after_ the first found token, or at point-max if none is found. |
52107
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4540 |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4541 (let ((base (point))) |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4542 (if (c-major-mode-is 'c++-mode) |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4543 |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4544 ;; In C++ we need to take special care to handle operator |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4545 ;; tokens and those pesky template brackets. |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4546 (while (and |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4547 (c-syntactic-re-search-forward "[;{<=]" nil 'move t t) |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4548 (or |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4549 (c-end-of-current-token base) |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4550 ;; Handle operator identifiers, i.e. ignore any |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4551 ;; operator token preceded by "operator". |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4552 (save-excursion |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4553 (and (c-safe (c-backward-sexp) t) |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4554 (looking-at "operator\\([^_]\\|$\\)"))) |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4555 (and (eq (char-before) ?<) |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4556 (c-with-syntax-table c++-template-syntax-table |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4557 (if (c-safe (goto-char (c-up-list-forward (point)))) |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4558 t |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4559 (goto-char (point-max)) |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4560 nil))))) |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4561 (setq base (point))) |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4562 |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4563 (while (and |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4564 (c-syntactic-re-search-forward "[;{=]" nil 'move t t) |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4565 (c-end-of-current-token base)) |
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
4566 (setq base (point)))))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4567 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4568 (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
|
4569 ;; 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
|
4570 ;; 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
|
4571 ;; 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
|
4572 ;; 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
|
4573 ;; `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
|
4574 ;; 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
|
4575 ;; 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
|
4576 ;; 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
|
4577 ;; 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
|
4578 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4579 ;; 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
|
4580 ;; "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
|
4581 ;; 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
|
4582 (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
|
4583 (let* ((start (point)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4584 (last-stmt-start (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4585 (move (c-beginning-of-statement-1 lim t t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4586 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4587 ;; `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
|
4588 ;; want to continue if the block doesn't begin a top level |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
4589 ;; construct, i.e. if it isn't preceded by ';', '}', ':', bob, |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
4590 ;; or an open paren. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4591 (let ((beg (point)) tentative-move) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4592 (while (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4593 ;; Must check with c-opt-method-key in ObjC mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4594 (not (and c-opt-method-key |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4595 (looking-at c-opt-method-key))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4596 (/= last-stmt-start (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4597 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4598 (c-backward-syntactic-ws lim) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4599 (not (memq (char-before) '(?\; ?} ?: nil)))) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
4600 (save-excursion |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
4601 (backward-char) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
4602 (not (looking-at "\\s("))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4603 ;; Check that we don't move from the first thing in a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4604 ;; macro to its header. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4605 (not (eq (setq tentative-move |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4606 (c-beginning-of-statement-1 lim t t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4607 'macro))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4608 (setq last-stmt-start beg |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4609 beg (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4610 move tentative-move)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4611 (goto-char beg)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4612 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4613 (when c-recognize-knr-p |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4614 (let ((fallback-pos (point)) knr-argdecl-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4615 ;; Handle K&R argdecls. Back up after the "statement" jumped |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4616 ;; over by `c-beginning-of-statement-1', unless it was the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4617 ;; function body, in which case we're sitting on the opening |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4618 ;; brace now. Then test if we're in a K&R argdecl region and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4619 ;; that we started at the other side of the first argdecl in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4620 ;; it. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4621 (unless (eq (char-after) ?{) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4622 (goto-char last-stmt-start)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4623 (if (and (setq knr-argdecl-start (c-in-knr-argdecl lim)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4624 (< knr-argdecl-start start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4625 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4626 (goto-char knr-argdecl-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4627 (not (eq (c-beginning-of-statement-1 lim t t) 'macro)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4628 (throw 'return |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4629 (cons (if (eq (char-after fallback-pos) ?{) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4630 'previous |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4631 'same) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4632 knr-argdecl-start)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4633 (goto-char fallback-pos)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4634 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4635 (when c-opt-access-key |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4636 ;; Might have ended up before a protection label. This should |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4637 ;; perhaps be checked before `c-recognize-knr-p' to be really |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4638 ;; accurate, but we know that no language has both. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4639 (while (looking-at c-opt-access-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4640 (goto-char (match-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4641 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4642 (when (>= (point) start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4643 (goto-char start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4644 (throw 'return (cons 'same nil))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4645 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4646 ;; `c-beginning-of-statement-1' counts each brace block as a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4647 ;; separate statement, so the result will be 'previous if we've |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4648 ;; moved over any. If they were brace list initializers we might |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4649 ;; not have moved over a declaration boundary though, so change it |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4650 ;; to 'same if we've moved past a '=' before '{', but not ';'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4651 ;; (This ought to be integrated into `c-beginning-of-statement-1', |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4652 ;; so we avoid this extra pass which potentially can search over a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4653 ;; large amount of text.) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4654 (if (and (eq move 'previous) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4655 (c-with-syntax-table (if (c-major-mode-is 'c++-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4656 c++-template-syntax-table |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4657 (syntax-table)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4658 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4659 (and (c-syntactic-re-search-forward "[;={]" start t t t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4660 (eq (char-before) ?=) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4661 (c-syntactic-re-search-forward "[;{]" start t t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4662 (eq (char-before) ?{) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4663 (c-safe (goto-char (c-up-list-forward (point))) t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4664 (not (c-syntactic-re-search-forward ";" start t t)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4665 (cons 'same nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4666 (cons move nil))))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4667 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4668 (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
|
4669 ;; 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
|
4670 ;; 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
|
4671 ;; `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
|
4672 ;; 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
|
4673 ;; 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
|
4674 ;; 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
|
4675 ;; 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
|
4676 ;; `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
|
4677 (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
|
4678 (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
|
4679 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
|
4680 (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
|
4681 (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
|
4682 (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
|
4683 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4684 (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
|
4685 (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
|
4686 (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
|
4687 ;; 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
|
4688 ;; 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
|
4689 ;; `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
|
4690 ;; start. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4691 (c-syntactic-re-search-forward "{" nil 'move t)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4692 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4693 (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
|
4694 ;; 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
|
4695 (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
|
4696 (goto-char (c-up-list-forward (point))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4697 (error (goto-char (point-max)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4698 (throw 'return nil))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4699 (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
|
4700 (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
|
4701 (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
|
4702 (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
|
4703 (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
|
4704 (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
|
4705 ;; 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
|
4706 ;; 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
|
4707 (c-syntactic-re-search-forward |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4708 (concat "[;=\(\[{]\\|\\(" |
45049
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
4709 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
|
4710 "\\)") |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4711 lim t t t) |
45049
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
4712 (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
|
4713 (not (eq (char-before) ?_)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4714 ;; Check that the first following paren is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4715 ;; the block. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4716 (c-syntactic-re-search-forward "[;=\(\[{]" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4717 lim t t t) |
45049
11c11cb2b8a8
(c-beginning-of-decl-1): Better way to handle protection labels, one
Martin Stjernholm <mast@lysator.liu.se>
parents:
44728
diff
changeset
|
4718 (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
|
4719 ;; 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
|
4720 ;; `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
|
4721 ;; 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
|
4722 (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
|
4723 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4724 (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
|
4725 (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
|
4726 (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
|
4727 (throw 'return t)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4728 (c-syntactic-re-search-forward ";" nil 'move t)))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4729 nil))) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
4730 |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
4731 (defun c-beginning-of-member-init-list (&optional limit) |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
4732 ;; Go to the beginning of a member init list (i.e. just after the |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4733 ;; ':') if inside one. Returns t in that case, nil otherwise. |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
4734 (or limit |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
4735 (setq limit (point-min))) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
4736 (skip-chars-forward " \t") |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4737 |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
4738 (if (eq (char-after) ?,) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
4739 (forward-char 1) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
4740 (c-backward-syntactic-ws limit)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4741 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4742 (catch 'exit |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4743 (while (and (< limit (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4744 (eq (char-before) ?,)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4745 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4746 ;; this will catch member inits with multiple |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4747 ;; line arglists |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4748 (forward-char -1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4749 (c-backward-syntactic-ws limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4750 (if (eq (char-before) ?\)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4751 (unless (c-safe (c-backward-sexp 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4752 (throw 'exit nil))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4753 (c-backward-syntactic-ws limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4754 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4755 ;; Skip over any template arg to the class. This way with a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4756 ;; syntax table is bogus but it'll have to do for now. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4757 (if (and (eq (char-before) ?>) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4758 (c-major-mode-is 'c++-mode)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4759 (c-with-syntax-table c++-template-syntax-table |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4760 (unless (c-safe (c-backward-sexp 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4761 (throw 'exit nil)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4762 (c-safe (c-backward-sexp 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4763 (c-backward-syntactic-ws limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4764 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4765 ;; Skip backwards over a fully::qualified::name. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4766 (while (and (eq (char-before) ?:) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4767 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4768 (forward-char -1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4769 (eq (char-before) ?:))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4770 (backward-char 2) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4771 (c-safe (c-backward-sexp 1))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4772 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4773 ;; If we've stepped over a number then this is a bitfield. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4774 (when (and c-opt-bitfield-key |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4775 (looking-at "[0-9]")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4776 (throw 'exit nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4777 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4778 ;; now continue checking |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4779 (c-backward-syntactic-ws limit)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4780 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4781 (and (< limit (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4782 (eq (char-before) ?:)))) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
4783 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4784 (defun c-search-uplist-for-classkey (paren-state) |
18720 | 4785 ;; search for the containing class, returning a 2 element vector if |
24282 | 4786 ;; found. aref 0 contains the bufpos of the boi of the class key |
4787 ;; 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
|
4788 (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
|
4789 ;; no paren-state means we cannot be inside a class |
18720 | 4790 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
|
4791 (let ((carcache (car paren-state)) |
18720 | 4792 search-start search-end) |
4793 (if (consp carcache) | |
4794 ;; a cons cell in the first element means that there is some | |
4795 ;; balanced sexp before the current bufpos. this we can | |
4796 ;; ignore. the nth 1 and nth 2 elements define for us the | |
4797 ;; 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
|
4798 (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
|
4799 search-end (nth 1 paren-state)) |
18720 | 4800 ;; if the car was not a cons cell then nth 0 and nth 1 define |
4801 ;; 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
|
4802 (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
|
4803 search-end (nth 0 paren-state))) |
18720 | 4804 ;; if search-end is nil, or if the search-end character isn't an |
4805 ;; open brace, we are definitely not in a class | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4806 (if (or (not search-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4807 (< search-end (point-min)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4808 (not (eq (char-after search-end) ?{))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4809 nil |
18720 | 4810 ;; now, we need to look more closely at search-start. if |
4811 ;; search-start is nil, then our start boundary is really | |
4812 ;; point-min. | |
4813 (if (not search-start) | |
4814 (setq search-start (point-min)) | |
4815 ;; if search-start is a cons cell, then we can start | |
4816 ;; searching from the end of the balanced sexp just ahead of | |
4817 ;; us | |
4818 (if (consp search-start) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4819 (setq search-start (cdr search-start)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4820 ;; Otherwise we start searching within the surrounding paren sexp. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4821 (setq search-start (1+ search-start)))) |
18720 | 4822 ;; now we can do a quick regexp search from search-start to |
4823 ;; search-end and see if we can find a class key. watch for | |
4824 ;; class like strings in literals | |
4825 (save-excursion | |
4826 (save-restriction | |
4827 (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
|
4828 (let (foundp class match-end) |
18720 | 4829 (while (and (not foundp) |
4830 (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
|
4831 (c-forward-syntactic-ws search-end) |
18720 | 4832 (> search-end (point))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4833 ;; Add one to the search limit, to allow |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4834 ;; matching of the "{" in the regexp. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4835 (re-search-forward c-decl-block-key |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4836 (1+ search-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4837 t)) |
18720 | 4838 (setq class (match-beginning 0) |
4839 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
|
4840 (goto-char class) |
18720 | 4841 (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
|
4842 (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
|
4843 (c-skip-ws-forward) |
18720 | 4844 (setq foundp (vector (c-point 'boi) search-end)) |
4845 (cond | |
4846 ;; check for embedded keywords | |
4847 ((let ((char (char-after (1- class)))) | |
4848 (and char | |
4849 (memq (char-syntax char) '(?w ?_)))) | |
4850 (goto-char match-end) | |
4851 (setq foundp nil)) | |
4852 ;; 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
|
4853 ;; 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
|
4854 ((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
|
4855 (re-search-forward c-opt-method-key search-end t) |
24282 | 4856 (not (c-in-literal class))) |
18720 | 4857 (setq foundp nil)) |
24282 | 4858 ;; 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
|
4859 ((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
|
4860 (looking-at c-opt-inexpr-class-key)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4861 (while (and (zerop (c-forward-token-2 1 t)) |
24282 | 4862 (looking-at "(\\|\\w\\|\\s_\\|\\."))) |
4863 (if (eq (point) search-end) | |
4864 ;; We're done. Just trap this case in the cond. | |
4865 nil | |
4866 ;; False alarm; all conditions aren't satisfied. | |
4867 (setq foundp nil))) | |
18720 | 4868 ;; Its impossible to define a regexp for this, and |
4869 ;; nearly so to do it programmatically. | |
4870 ;; | |
4871 ;; ; picks up forward decls | |
4872 ;; = picks up init lists | |
4873 ;; ) picks up return types | |
4874 ;; > picks up templates, but remember that we can | |
4875 ;; inherit from templates! | |
4876 ((let ((skipchars "^;=)")) | |
4877 ;; try to see if we found the `class' keyword | |
4878 ;; inside a template arg list | |
4879 (save-excursion | |
4880 (skip-chars-backward "^<>" search-start) | |
4881 (if (eq (char-before) ?<) | |
4882 (setq skipchars (concat skipchars ">")))) | |
24282 | 4883 (while (progn |
4884 (skip-chars-forward skipchars search-end) | |
4885 (c-in-literal class)) | |
4886 (forward-char)) | |
18720 | 4887 (/= (point) search-end)) |
4888 (setq foundp nil)) | |
4889 ))) | |
4890 foundp)) | |
4891 ))))) | |
4892 | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4893 (defun c-inside-bracelist-p (containing-sexp paren-state) |
18720 | 4894 ;; return the buffer position of the beginning of the brace list |
4895 ;; statement if we're inside a brace list, otherwise return nil. | |
4896 ;; CONTAINING-SEXP is the buffer pos of the innermost containing | |
36920 | 4897 ;; paren. BRACE-STATE is the remainder of the state of enclosing |
4898 ;; braces | |
18720 | 4899 ;; |
4900 ;; N.B.: This algorithm can potentially get confused by cpp macros | |
4901 ;; places in inconvenient locations. Its a trade-off we make for | |
4902 ;; speed. | |
4903 (or | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4904 ;; This will pick up brace list declarations. |
21106
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
4905 (c-safe |
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
4906 (save-excursion |
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
4907 (goto-char containing-sexp) |
24282 | 4908 (c-forward-sexp -1) |
21106
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
4909 (let (bracepos) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4910 (if (and (or (looking-at c-brace-list-key) |
24282 | 4911 (progn (c-forward-sexp -1) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4912 (looking-at c-brace-list-key))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
4913 (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
|
4914 (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
|
4915 (- bracepos 2)))) |
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
4916 (point))))) |
18720 | 4917 ;; this will pick up array/aggregate init lists, even if they are nested. |
4918 (save-excursion | |
24282 | 4919 (let ((class-key |
4920 ;; Pike can have class definitions anywhere, so we must | |
4921 ;; check for the class key here. | |
4922 (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
|
4923 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
|
4924 bufpos braceassignp lim next-containing) |
18720 | 4925 (while (and (not bufpos) |
4926 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
|
4927 (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
|
4928 (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
|
4929 (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
|
4930 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
|
4931 (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
|
4932 (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
|
4933 (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
|
4934 paren-state (cdr paren-state)))) |
18720 | 4935 (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
|
4936 (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
|
4937 ;; 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
|
4938 ;; 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
|
4939 ;; 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
|
4940 ;; doesn't check for an identifier before it. |
24282 | 4941 (setq containing-sexp nil) |
4942 ;; see if the open brace is preceded by = or [...] in | |
4943 ;; 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
|
4944 (setq braceassignp 'dontknow) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4945 (c-backward-token-2 1 t lim) |
25178
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
4946 ;; Checks to do only on the first sexp before the brace. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4947 (when (and c-opt-inexpr-brace-list-key |
25178
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
4948 (eq (char-after) ?\[)) |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
4949 ;; 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
|
4950 ;; 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
|
4951 ;; earlier. |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
4952 (while (eq braceassignp 'dontknow) |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
4953 (setq braceassignp |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4954 (cond ((/= (c-backward-token-2 1 t lim) 0) nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4955 ((looking-at c-opt-inexpr-brace-list-key) t) |
25178
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
4956 ((looking-at "\\sw\\|\\s_\\|[.[]") |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
4957 ;; 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
|
4958 ;; identifier (may contain "." in Java) |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
4959 ;; or another "[]" sexp. |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
4960 'dontknow) |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
4961 (t nil))))) |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
4962 ;; 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
|
4963 ;; beginning of the statement. |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
4964 (while (eq braceassignp 'dontknow) |
24282 | 4965 (cond ((eq (char-after) ?\;) |
4966 (setq braceassignp nil)) | |
4967 ((and class-key | |
4968 (looking-at class-key)) | |
4969 (setq braceassignp nil)) | |
4970 ((eq (char-after) ?=) | |
4971 ;; We've seen a =, but must check earlier tokens so | |
4972 ;; that it isn't something that should be ignored. | |
4973 (setq braceassignp 'maybe) | |
4974 (while (and (eq braceassignp 'maybe) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
4975 (zerop (c-backward-token-2 1 t lim))) |
24282 | 4976 (setq braceassignp |
4977 (cond | |
4978 ;; 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
|
4979 ((looking-at "operator\\>[^_]") nil) |
36920 | 4980 ;; Check for `<opchar>= in Pike. |
4981 ((and (c-major-mode-is 'pike-mode) | |
4982 (or (eq (char-after) ?`) | |
4983 ;; Special case for Pikes | |
4984 ;; `[]=, since '[' is not in | |
4985 ;; the punctuation class. | |
4986 (and (eq (char-after) ?\[) | |
4987 (eq (char-before) ?`)))) | |
4988 nil) | |
24282 | 4989 ((looking-at "\\s.") 'maybe) |
4990 ;; make sure we're not in a C++ template | |
4991 ;; 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
|
4992 ((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
|
4993 (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
|
4994 (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
|
4995 (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
|
4996 (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
|
4997 (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
|
4998 (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
|
4999 (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
|
5000 (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
|
5001 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
|
5002 (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
|
5003 )))) |
24282 | 5004 nil) |
25178
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
5005 (t t)))))) |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
5006 (if (and (eq braceassignp 'dontknow) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5007 (/= (c-backward-token-2 1 t lim) 0)) |
25178
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
5008 (setq braceassignp nil))) |
1dc57e616e8d
(c-inside-bracelist-p): Tighter test for
Richard M. Stallman <rms@gnu.org>
parents:
24335
diff
changeset
|
5009 (if (not braceassignp) |
24282 | 5010 (if (eq (char-after) ?\;) |
5011 ;; Brace lists can't contain a semicolon, so we're done. | |
5012 (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
|
5013 ;; 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
|
5014 (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
|
5015 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
|
5016 next-containing nil)) |
24282 | 5017 ;; we've hit the beginning of the aggregate list |
5018 (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
|
5019 (c-most-enclosing-brace paren-state)) |
24282 | 5020 (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
|
5021 ) |
18720 | 5022 bufpos)) |
5023 )) | |
5024 | |
24282 | 5025 (defun c-looking-at-special-brace-list (&optional lim) |
5026 ;; 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
|
5027 ;; `([ ])', `(< >)' etc, a cons of a cons of its starting and ending |
24282 | 5028 ;; positions and its entry in c-special-brace-lists is returned, nil |
5029 ;; otherwise. The ending position is nil if the list is still open. | |
5030 ;; LIM is the limit for forward search. The point may either be at | |
5031 ;; the `(' or at the following paren character. Tries to check the | |
5032 ;; matching closer, but assumes it's correct if no balanced paren is | |
5033 ;; found (i.e. the case `({ ... } ... )' is detected as _not_ being | |
5034 ;; a special brace list). | |
5035 (if c-special-brace-lists | |
5036 (condition-case () | |
5037 (save-excursion | |
5038 (let ((beg (point)) | |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5039 inner-beg end type) |
24282 | 5040 (c-forward-syntactic-ws) |
5041 (if (eq (char-after) ?\() | |
5042 (progn | |
5043 (forward-char 1) | |
5044 (c-forward-syntactic-ws) | |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5045 (setq inner-beg (point)) |
24282 | 5046 (setq type (assq (char-after) c-special-brace-lists))) |
5047 (if (setq type (assq (char-after) c-special-brace-lists)) | |
5048 (progn | |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5049 (setq inner-beg (point)) |
24282 | 5050 (c-backward-syntactic-ws) |
5051 (forward-char -1) | |
5052 (setq beg (if (eq (char-after) ?\() | |
5053 (point) | |
5054 nil))))) | |
5055 (if (and beg type) | |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5056 (if (and (c-safe |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5057 (goto-char beg) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5058 (c-forward-sexp 1) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5059 (setq end (point)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5060 (= (char-before) ?\))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5061 (c-safe |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5062 (goto-char inner-beg) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5063 (if (looking-at "\\s(") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5064 ;; Check balancing of the inner paren |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5065 ;; below. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5066 (progn |
24282 | 5067 (c-forward-sexp 1) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5068 t) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5069 ;; If the inner char isn't a paren then |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5070 ;; we can't check balancing, so just |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5071 ;; check the char before the outer |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5072 ;; closing paren. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5073 (goto-char end) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5074 (backward-char) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5075 (c-backward-syntactic-ws) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
5076 (= (char-before) (cdr type))))) |
24282 | 5077 (if (or (/= (char-syntax (char-before)) ?\)) |
5078 (= (progn | |
5079 (c-forward-syntactic-ws) | |
5080 (point)) | |
5081 (1- end))) | |
5082 (cons (cons beg end) type)) | |
5083 (cons (list beg) type))))) | |
5084 (error nil)))) | |
5085 | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5086 (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
|
5087 ;; 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
|
5088 ;; 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
|
5089 (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
|
5090 (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
|
5091 (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
|
5092 ;; 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
|
5093 ;; 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
|
5094 (memq (char-before) '(?\; ?} ?\()) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
5095 (and (eq (char-before) ?{) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
5096 (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
|
5097 (progn (backward-char) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
5098 (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
|
5099 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5100 (defun c-looking-at-inexpr-block (lim containing-sexp) |
24282 | 5101 ;; Returns non-nil if we're looking at the beginning of a block |
5102 ;; inside an expression. The value returned is actually a cons of | |
5103 ;; either 'inlambda, 'inexpr-statement or 'inexpr-class and the | |
5104 ;; 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
|
5105 ;; 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
|
5106 ;; 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
|
5107 ;; 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
|
5108 ;; 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
|
5109 ;; back. |
24282 | 5110 (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
|
5111 (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
|
5112 (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
|
5113 ;; 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
|
5114 ;; 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
|
5115 (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
|
5116 (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
|
5117 (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
|
5118 (> (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
|
5119 (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
|
5120 (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
|
5121 (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
|
5122 (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
|
5123 (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
|
5124 (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
|
5125 (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
|
5126 ((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
|
5127 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
|
5128 (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
|
5129 (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
|
5130 (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
|
5131 ;; 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
|
5132 ;; 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
|
5133 ;; 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
|
5134 (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
|
5135 (while (and |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5136 (= (c-backward-token-2 1 nil closest-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
|
5137 (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
|
5138 (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
|
5139 (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
|
5140 (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
|
5141 ;; 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
|
5142 ;; 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
|
5143 ;; 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
|
5144 (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
|
5145 (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
|
5146 (progn (goto-char block-follows) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5147 (zerop (c-forward-token-2 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
|
5148 (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
|
5149 (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
|
5150 ((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
|
5151 (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
|
5152 (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
|
5153 ((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
|
5154 (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
|
5155 (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
|
5156 ((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
|
5157 (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
|
5158 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
|
5159 (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
|
5160 (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
|
5161 (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
|
5162 '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
|
5163 (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
|
5164 (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
|
5165 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
|
5166 (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
|
5167 (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
|
5168 (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
|
5169 (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
|
5170 (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
|
5171 (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
|
5172 (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
|
5173 (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
|
5174 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
|
5175 (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
|
5176 res)))) |
24282 | 5177 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5178 (defun c-looking-at-inexpr-block-backward (paren-state) |
24282 | 5179 ;; Returns non-nil if we're looking at the end of an in-expression |
5180 ;; 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
|
5181 ;; PAREN-STATE is the paren state relevant at the current position. |
24282 | 5182 (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
|
5183 ;; 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
|
5184 (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
|
5185 (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
|
5186 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
|
5187 (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
|
5188 (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
|
5189 (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
|
5190 (= (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
|
5191 (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
|
5192 (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
|
5193 (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
|
5194 (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
|
5195 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
|
5196 containing-sexp))))) |
24282 | 5197 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5198 (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
|
5199 ;; 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
|
5200 ;; 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
|
5201 (setq paren-state (c-whack-state-after (point) paren-state)) |
18720 | 5202 (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
|
5203 (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
|
5204 (setq inclass-p (c-search-uplist-for-classkey paren-state)) |
18720 | 5205 (narrow-to-region |
5206 (progn | |
5207 (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
|
5208 (c-skip-ws-forward lim) |
18720 | 5209 ;; if point is now left of the class opening brace, we're |
5210 ;; hosed, so try a different tact | |
5211 (if (<= (point) (aref inclass-p 1)) | |
5212 (progn | |
5213 (goto-char (1+ (aref inclass-p 1))) | |
5214 (c-forward-syntactic-ws lim))) | |
5215 (point)) | |
5216 ;; end point is the end of the current line | |
5217 (progn | |
5218 (goto-char lim) | |
5219 (c-point 'eol)))) | |
5220 ;; return the class vector | |
5221 inclass-p)) | |
5222 | |
5223 | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5224 ;; `c-guess-basic-syntax' and the functions that precedes it below |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5225 ;; implements the main decision tree for determining the syntactic |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5226 ;; analysis of the current line of code. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5227 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5228 ;; Dynamically bound to t when `c-guess-basic-syntax' is called during |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5229 ;; auto newline analysis. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5230 (defvar c-auto-newline-analysis nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5231 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5232 (defsubst c-add-syntax (symbol &rest args) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5233 ;; A simple function to prepend a new syntax element to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5234 ;; `c-syntactic-context'. Using `setq' on it is unsafe since it |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5235 ;; should always be dynamically bound but since we read it first |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5236 ;; we'll fail properly anyway if this function is misused. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5237 (setq c-syntactic-context (cons (cons symbol args) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5238 c-syntactic-context))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5239 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5240 (defsubst c-append-syntax (symbol &rest args) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5241 ;; Like `c-add-syntax' but appends to the end of the syntax list. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5242 ;; (Normally not necessary.) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5243 (setq c-syntactic-context (nconc c-syntactic-context |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5244 (list (cons symbol args))))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5245 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5246 (defun c-add-stmt-syntax (syntax-symbol |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5247 syntax-extra-args |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5248 stop-at-boi-only |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5249 at-block-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
|
5250 containing-sexp |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5251 paren-state) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5252 ;; 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
|
5253 ;; 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
|
5254 ;; 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
|
5255 ;; 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
|
5256 ;; 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
|
5257 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5258 ;; 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
|
5259 ;; given SYNTAX-SYMBOL. More syntax entries are added if we need to |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5260 ;; skip past open parens and containing statements. All the added |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5261 ;; 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
|
5262 ;; |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5263 ;; SYNTAX-EXTRA-ARGS are a list of the extra arguments for the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5264 ;; syntax symbol. They are appended after the anchor point. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5265 ;; |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5266 ;; 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
|
5267 ;; 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
|
5268 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5269 ;; 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
|
5270 ;; 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
|
5271 ;; 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
|
5272 ;; 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
|
5273 (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
|
5274 ;; 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
|
5275 ;; treatment. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5276 (apply 'c-add-syntax syntax-symbol (point) syntax-extra-args) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5277 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5278 (let ((savepos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5279 (syntax-last c-syntactic-context) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5280 (boi (c-point 'boi)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5281 (prev-paren (if at-block-start ?{ (char-after))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5282 step-type step-tmp at-comment special-list) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5283 (apply 'c-add-syntax syntax-symbol nil syntax-extra-args) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5284 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5285 ;; 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
|
5286 ;; 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
|
5287 (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
|
5288 (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
|
5289 (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
|
5290 '(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
|
5291 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
|
5292 (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
|
5293 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
|
5294 (/= (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
|
5295 (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
|
5296 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
|
5297 |
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
|
5298 (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
|
5299 ;; 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
|
5300 (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
|
5301 (progn |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5302 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5303 ;; 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
|
5304 (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
|
5305 (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
|
5306 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5307 ;; 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
|
5308 ;; 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
|
5309 (while (and (/= (setq savepos (point)) boi) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5310 (c-backward-single-comment)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5311 (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
|
5312 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
|
5313 (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
|
5314 |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
5315 (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
|
5316 (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
|
5317 (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
|
5318 (/= 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
|
5319 |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5320 (let ((save-step-type step-type)) |
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
|
5321 ;; 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
|
5322 ;; 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
|
5323 (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
|
5324 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
|
5325 |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
5326 (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
|
5327 (/= 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
|
5328 (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
|
5329 ;; 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
|
5330 ;; 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
|
5331 ;; 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
|
5332 ;; 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
|
5333 (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
|
5334 (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
|
5335 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
|
5336 (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
|
5337 (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
|
5338 ;; 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
|
5339 ;; 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
|
5340 ;; 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
|
5341 (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
|
5342 |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
5343 ;; 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
|
5344 ;; 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
|
5345 ;; 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
|
5346 ;; 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
|
5347 (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
|
5348 (< (point) boi)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5349 (c-add-syntax 'substatement 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
|
5350 |
17fef404cef1
(c-add-stmt-syntax): Fixed some cases of wrong anchoring, e.g. for
Martin Stjernholm <mast@lysator.liu.se>
parents:
45049
diff
changeset
|
5351 (setq boi (c-point 'boi)) |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5352 (if (= (point) savepos) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5353 (progn |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5354 (setq step-type save-step-type) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5355 nil) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5356 t))))) |
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
|
5357 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5358 (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
|
5359 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
|
5360 (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
|
5361 |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5362 (when (and containing-sexp |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5363 (if (memq step-type '(nil same)) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5364 (/= (point) boi) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5365 (eq step-type '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
|
5366 (goto-char containing-sexp) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5367 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5368 ;; Don't stop in the middle of a special brace list opener |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5369 ;; like "({". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5370 (when (and c-special-brace-lists |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5371 (setq special-list |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5372 (c-looking-at-special-brace-list))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5373 (setq containing-sexp (car (car special-list))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5374 (goto-char containing-sexp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5375 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5376 (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
|
5377 paren-state) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5378 containing-sexp (c-most-enclosing-brace paren-state) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5379 savepos (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5380 boi (c-point 'boi)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5381 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5382 (if (eq (setq prev-paren (char-after)) ?\() |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5383 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5384 (c-backward-syntactic-ws containing-sexp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5385 (when (/= savepos boi) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5386 (if (and (or (not (looking-at "\\>")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5387 (not (c-on-identifier))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5388 (not special-list) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5389 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5390 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5391 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5392 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5393 (eq (char-after) ?{))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5394 ;; We're in an in-expression statement. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5395 ;; This syntactic element won't get an anchor pos. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5396 (c-add-syntax 'inexpr-statement) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5397 (c-add-syntax 'arglist-cont-nonempty nil savepos))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5398 (goto-char (max boi |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5399 (if containing-sexp |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5400 (1+ containing-sexp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5401 (point-min)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5402 (setq step-type 'same)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5403 (setq step-type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5404 (c-beginning-of-statement-1 containing-sexp))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5405 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5406 (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
|
5407 (/= 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
|
5408 (eq prev-paren ?{)))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5409 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5410 (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
|
5411 ;; 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
|
5412 ;; 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
|
5413 ;; 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
|
5414 ;; 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
|
5415 (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
|
5416 (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
|
5417 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5418 (when (eq prev-paren ?{) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5419 (c-add-syntax (if at-bod |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5420 'defun-block-intro |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5421 'statement-block-intro) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5422 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
|
5423 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5424 (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
|
5425 ;; 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
|
5426 ;; 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
|
5427 (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
|
5428 ;; 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
|
5429 ;; 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
|
5430 ;; 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
|
5431 (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
|
5432 (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
|
5433 (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
|
5434 (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
|
5435 (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
|
5436 ))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5437 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5438 ;; Fill in the current point as the anchor for all the symbols |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5439 ;; added above. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5440 (let ((p c-syntactic-context)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5441 (while (not (eq p syntax-last)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5442 (if (cdr (car p)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5443 (setcar (cdr (car p)) (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5444 (setq p (cdr p)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5445 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5446 ))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5447 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5448 (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
|
5449 ;; 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
|
5450 ;; 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
|
5451 ;; 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
|
5452 (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
|
5453 (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
|
5454 (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
|
5455 (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
|
5456 (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
|
5457 (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
|
5458 (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
|
5459 (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
|
5460 (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
|
5461 (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
|
5462 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
|
5463 (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
|
5464 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
|
5465 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
|
5466 (/= 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
|
5467 (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
|
5468 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
|
5469 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5470 (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
|
5471 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
|
5472 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
|
5473 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
|
5474 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
|
5475 ;; 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
|
5476 ;; 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
|
5477 ;; construct of some kind. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5478 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5479 (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
|
5480 (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
|
5481 (skip-chars-forward " \t") |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5482 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5483 (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
|
5484 ;; (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
|
5485 ;; 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
|
5486 ((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
|
5487 (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
|
5488 (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
|
5489 (eq char-after-ip ?{))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5490 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5491 (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
|
5492 ;; 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
|
5493 ((save-excursion |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5494 (skip-chars-forward "{") |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5495 (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
|
5496 (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
|
5497 (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
|
5498 )) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5499 (c-add-syntax 'class-open beg-of-same-or-containing-stmt)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5500 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5501 ;; 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
|
5502 ((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
|
5503 (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
|
5504 (goto-char beg-of-same-or-containing-stmt) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5505 (c-syntactic-re-search-forward "=\\([^=]\\|$\\)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5506 indent-point t t t))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5507 ;; The most semantically accurate symbol here is |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5508 ;; brace-list-open, but we normally report it simply as a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5509 ;; statement-cont. The reason is that one normally adjusts |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5510 ;; brace-list-open for brace lists as top-level constructs, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5511 ;; and brace lists inside statements is a completely different |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5512 ;; context. C.f. case 5A.3. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5513 (c-beginning-of-statement-1 containing-sexp) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5514 (c-add-stmt-syntax (if c-auto-newline-analysis |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5515 ;; Turn off the dwim above when we're |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5516 ;; analyzing the nature of the brace |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5517 ;; for the auto newline feature. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5518 'brace-list-open |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5519 'statement-cont) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5520 nil nil nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5521 containing-sexp paren-state)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5522 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5523 ;; 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
|
5524 ;; block. Can occur e.g. in Pike and when using gcc |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5525 ;; extensions, but watch out for macros followed by blocks. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5526 ;; C.f. cases E, 16F and 17G. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5527 ((and (not (c-looking-at-bos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5528 (eq (c-beginning-of-statement-1 containing-sexp nil nil t) |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5529 'same) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5530 (save-excursion |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5531 ;; Look for a type followed by a symbol, i.e. the start of a |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5532 ;; function declaration. Doesn't work for declarations like |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5533 ;; "int *foo() ..."; we'd need to refactor the more competent |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5534 ;; analysis in `c-font-lock-declarations' for that. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5535 (and (c-forward-type) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5536 (progn |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5537 (c-forward-syntactic-ws) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5538 (looking-at c-symbol-start))))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5539 (c-add-stmt-syntax 'defun-open nil t nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5540 containing-sexp paren-state)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5541 |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5542 ;; CASE B.4: Continued statement with block open. The most |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5543 ;; accurate analysis is perhaps `statement-cont' together with |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5544 ;; `block-open' but we play DWIM and use `substatement-open' |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5545 ;; instead. The rationaly is that this typically is a macro |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5546 ;; followed by a block which makes it very similar to a |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5547 ;; statement with a substatement block. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5548 (t |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5549 (c-add-stmt-syntax 'substatement-open nil nil nil |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5550 containing-sexp paren-state)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5551 )) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5552 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5553 ;; CASE C: iostream insertion or extraction operator |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5554 ((and (looking-at "\\(<<\\|>>\\)\\([^=]\\|$\\)") |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5555 (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
|
5556 (goto-char beg-of-same-or-containing-stmt) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5557 ;; If there is no preceding streamop in the statement |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5558 ;; then indent this line as a normal statement-cont. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5559 (when (c-syntactic-re-search-forward |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5560 "\\(<<\\|>>\\)\\([^=]\\|$\\)" indent-point 'move t t) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5561 (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
|
5562 t)))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5563 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5564 ;; CASE E: In the "K&R region" of a function declared inside a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5565 ;; normal block. C.f. case B.3. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5566 ((and (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5567 ;; Check that the next token is a '{'. This works as |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5568 ;; long as no language that allows nested function |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5569 ;; definitions allows stuff like member init lists, K&R |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5570 ;; declarations or throws clauses there. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5571 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5572 ;; Note that we do a forward search for something ahead |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5573 ;; of the indentation line here. That's not good since |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5574 ;; the user might not have typed it yet. Unfortunately |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5575 ;; it's exceedingly tricky to recognize a function |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5576 ;; prototype in a code block without resorting to this. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5577 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5578 (eq (char-after) ?{)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5579 (not (c-looking-at-bos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5580 (eq (c-beginning-of-statement-1 containing-sexp nil nil t) |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5581 'same) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5582 (save-excursion |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5583 ;; Look for a type followed by a symbol, i.e. the start of a |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5584 ;; function declaration. Doesn't work for declarations like "int |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5585 ;; *foo() ..."; we'd need to refactor the more competent analysis |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5586 ;; in `c-font-lock-declarations' for that. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5587 (and (c-forward-type) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5588 (progn |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5589 (c-forward-syntactic-ws) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
5590 (looking-at c-symbol-start))))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5591 (c-add-stmt-syntax 'func-decl-cont nil t nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5592 containing-sexp paren-state)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5593 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5594 ;; 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
|
5595 (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
|
5596 (c-beginning-of-statement-1 containing-sexp) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5597 (c-add-stmt-syntax 'statement-cont nil nil nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5598 containing-sexp paren-state)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5599 ))) |
18720 | 5600 |
5601 (defun c-guess-basic-syntax () | |
51829
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5602 "Return the syntactic context of the current line. |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5603 This function does not do any hidden buffer changes." |
18720 | 5604 (save-excursion |
5605 (save-restriction | |
5606 (beginning-of-line) | |
51829
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5607 (c-save-buffer-state |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5608 ((indent-point (point)) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5609 (case-fold-search nil) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5610 (paren-state (c-parse-state)) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5611 literal containing-sexp char-before-ip char-after-ip lim |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5612 c-syntactic-context placeholder c-in-literal-cache step-type |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5613 tmpsymbol keyword injava-inher special-brace-list |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5614 ;; narrow out any enclosing class or extern "C" block |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5615 (inclass-p (c-narrow-out-enclosing-class paren-state |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5616 indent-point)) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5617 ;; `c-state-cache' is shadowed here so that we don't |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5618 ;; throw it away due to the narrowing that might be done |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5619 ;; by the function above. That means we must not do any |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5620 ;; changes during the execution of this function, since |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5621 ;; `c-invalidate-state-cache' then would change this local |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5622 ;; variable and leave a bogus value in the global one. |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5623 (c-state-cache (if inclass-p |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5624 (c-whack-state-before (point-min) paren-state) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5625 paren-state)) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5626 (c-state-cache-start (point-min)) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5627 inenclosing-p macro-start in-macro-expr |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5628 ;; There's always at most one syntactic element which got |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5629 ;; a relpos. It's stored in syntactic-relpos. |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5630 syntactic-relpos |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
5631 (c-stmt-delim-chars c-stmt-delim-chars)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5632 ;; Check for meta top-level enclosing constructs such as |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5633 ;; extern language definitions. |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
5634 (save-excursion |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
5635 (save-restriction |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
5636 (widen) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5637 (when (and inclass-p |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5638 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5639 (goto-char (aref inclass-p 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5640 (looking-at c-other-decl-block-key))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5641 (setq inenclosing-p (match-string 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5642 (if (string-equal inenclosing-p "extern") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5643 ;; Compatibility with legacy choice of name for the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5644 ;; extern-lang syntactic symbols. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5645 (setq inenclosing-p "extern-lang"))))) |
18720 | 5646 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5647 ;; 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
|
5648 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5649 ;; 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
|
5650 ;; 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
|
5651 ;; 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
|
5652 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5653 ;; 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
|
5654 ;; (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
|
5655 ;; 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
|
5656 ;; 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
|
5657 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5658 ;; 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
|
5659 ;; 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
|
5660 ;; 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
|
5661 ;; |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5662 ;; 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
|
5663 ;; 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
|
5664 ;; 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
|
5665 ;; 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
|
5666 (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
|
5667 (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
|
5668 (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
|
5669 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
|
5670 (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
|
5671 (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
|
5672 (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
|
5673 (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
|
5674 ;; 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
|
5675 ;; 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
|
5676 (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
|
5677 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
|
5678 ;; 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
|
5679 ;; 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
|
5680 (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
|
5681 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
|
5682 (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
|
5683 (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
|
5684 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5685 ;; 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
|
5686 ;; "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
|
5687 ;; 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
|
5688 ;; 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
|
5689 ;; 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
|
5690 (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
|
5691 (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
|
5692 (setq c-stmt-delim-chars c-stmt-delim-chars-with-comma)) |
18720 | 5693 |
5694 ;; cache char before and after indent point, and move point to | |
5695 ;; the most likely position to perform the majority of tests | |
5696 (goto-char indent-point) | |
5697 (c-backward-syntactic-ws lim) | |
5698 (setq char-before-ip (char-before)) | |
5699 (goto-char indent-point) | |
5700 (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
|
5701 (setq char-after-ip (char-after)) |
18720 | 5702 |
5703 ;; are we in a literal? | |
5704 (setq literal (c-in-literal lim)) | |
5705 | |
5706 ;; now figure out syntactic qualities of the current line | |
5707 (cond | |
5708 ;; 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
|
5709 ((eq literal 'string) |
18720 | 5710 (c-add-syntax 'string (c-point 'bopl))) |
5711 ;; CASE 2: in a C or C++ style comment. | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5712 ((and (memq literal '(c c++)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5713 ;; This is a kludge for XEmacs where we use |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5714 ;; `buffer-syntactic-context', which doesn't correctly |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5715 ;; recognize "\*/" to end a block comment. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5716 ;; `parse-partial-sexp' which is used by |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5717 ;; `c-literal-limits' will however do that in most |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5718 ;; versions, which results in that we get nil from |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5719 ;; `c-literal-limits' even when `c-in-literal' claims |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5720 ;; we're inside a comment. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5721 (setq placeholder (c-literal-limits lim))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5722 (c-add-syntax literal (car placeholder))) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
5723 ;; 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
|
5724 ((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
|
5725 (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
|
5726 (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
|
5727 (/= 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
|
5728 (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
|
5729 (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
|
5730 (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
|
5731 (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
|
5732 (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
|
5733 ;; 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
|
5734 ;; 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
|
5735 ;; 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
|
5736 ;; 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
|
5737 ;; 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
|
5738 ;; 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
|
5739 (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
|
5740 (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
|
5741 (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
|
5742 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
|
5743 (= (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
|
5744 (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
|
5745 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
|
5746 (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
|
5747 (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
|
5748 ;; 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
|
5749 ((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
|
5750 (c-beginning-of-statement-1 containing-sexp) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5751 (c-add-stmt-syntax 'else-clause nil t nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5752 containing-sexp paren-state)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5753 ;; 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
|
5754 ((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
|
5755 (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
|
5756 (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
|
5757 '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
|
5758 (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
|
5759 (goto-char placeholder) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5760 (c-add-stmt-syntax 'do-while-closure nil t nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5761 containing-sexp paren-state)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5762 ;; 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
|
5763 ;; 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
|
5764 ;; 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
|
5765 ((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
|
5766 (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
|
5767 (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
|
5768 ((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
|
5769 (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
|
5770 (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
|
5771 (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
|
5772 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
|
5773 (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
|
5774 (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
|
5775 (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
|
5776 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
|
5777 (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
|
5778 (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
|
5779 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
|
5780 (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
|
5781 (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
|
5782 (goto-char placeholder) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5783 (c-add-stmt-syntax 'catch-clause nil t nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5784 containing-sexp paren-state)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5785 ;; 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
|
5786 ((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
|
5787 (and c-opt-block-stmt-key |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5788 (if (c-mode-is-new-awk-p) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5789 (c-awk-prev-line-incomplete-p containing-sexp) ; ACM 2002/3/29 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5790 (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
|
5791 (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
|
5792 (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
|
5793 (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
|
5794 (> (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
|
5795 (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
|
5796 ;; 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
|
5797 ;; 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
|
5798 (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
|
5799 (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
|
5800 (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
|
5801 '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
|
5802 (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
|
5803 (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
|
5804 (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
|
5805 (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
|
5806 (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
|
5807 ;; 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
|
5808 ;; 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
|
5809 (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
|
5810 (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
|
5811 (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
|
5812 (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
|
5813 '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
|
5814 (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
|
5815 (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
|
5816 ;; 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
|
5817 (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
|
5818 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
|
5819 (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
|
5820 ;; 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
|
5821 ;; 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
|
5822 ;; 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
|
5823 ;; modifier. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5824 (and (zerop (c-forward-token-2 1 nil)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5825 (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
|
5826 (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
|
5827 (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
|
5828 ;; 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
|
5829 (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
|
5830 (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
|
5831 (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
|
5832 ((eq char-after-ip ?{) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5833 (c-add-stmt-syntax 'substatement-open nil nil nil |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5834 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
|
5835 ((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
|
5836 (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
|
5837 (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
|
5838 (looking-at c-label-key)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5839 (c-add-stmt-syntax 'substatement-label nil nil nil |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5840 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
|
5841 (t |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5842 (c-add-stmt-syntax 'substatement nil nil nil |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
5843 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
|
5844 ;; 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
|
5845 ;; 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
|
5846 (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
|
5847 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
|
5848 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
|
5849 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
|
5850 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
|
5851 ;; 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
|
5852 ;; 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
|
5853 ((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
|
5854 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
|
5855 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
|
5856 (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
|
5857 (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
|
5858 containing-sexp))) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
5859 (setq tmpsymbol (assq (car placeholder) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
5860 '((inexpr-class . class-open) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
5861 (inexpr-statement . block-open)))) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
5862 (if tmpsymbol |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
5863 ;; 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
|
5864 (setq tmpsymbol (cdr tmpsymbol)) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
5865 ;; 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
|
5866 ;; 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
|
5867 ;; opener. |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
5868 (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
|
5869 'inline-open |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
5870 'lambda-intro-cont))) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
5871 (goto-char (cdr placeholder)) |
36920 | 5872 (back-to-indentation) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5873 (c-add-stmt-syntax tmpsymbol nil t 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
|
5874 (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
|
5875 (c-whack-state-after (point) paren-state)) |
36920 | 5876 (unless (eq (point) (cdr placeholder)) |
5877 (c-add-syntax (car placeholder)))) | |
18720 | 5878 ;; CASE 5: Line is at top level. |
5879 ((null containing-sexp) | |
5880 (cond | |
24282 | 5881 ;; CASE 5A: we are looking at a defun, brace list, class, |
5882 ;; or inline-inclass method opening brace | |
5883 ((setq special-brace-list | |
5884 (or (and c-special-brace-lists | |
5885 (c-looking-at-special-brace-list)) | |
5886 (eq char-after-ip ?{))) | |
18720 | 5887 (cond |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5888 ;; CASE 5A.1: Non-class declaration block open. |
18720 | 5889 ((save-excursion |
5890 (goto-char indent-point) | |
5891 (skip-chars-forward " \t") | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5892 (and (c-safe (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
|
5893 (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
|
5894 (setq keyword (match-string 1) |
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
5895 placeholder (point)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5896 (if (string-equal keyword "extern") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5897 ;; Special case for extern-lang-open. The |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5898 ;; check for a following string is disabled |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5899 ;; since it doesn't disambiguate anything. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5900 (and ;;(progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5901 ;; (c-forward-sexp 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5902 ;; (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5903 ;; (eq (char-after) ?\")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5904 (setq tmpsymbol 'extern-lang-open)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5905 (setq tmpsymbol (intern (concat keyword "-open")))) |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
5906 )) |
18720 | 5907 (goto-char placeholder) |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
5908 (c-add-syntax tmpsymbol (c-point 'boi))) |
18720 | 5909 ;; CASE 5A.2: we are looking at a class opening brace |
5910 ((save-excursion | |
5911 (goto-char indent-point) | |
5912 (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
|
5913 (let ((decl (c-search-uplist-for-classkey (c-parse-state)))) |
18720 | 5914 (and decl |
5915 (setq placeholder (aref decl 0))) | |
5916 )) | |
5917 (c-add-syntax 'class-open placeholder)) | |
5918 ;; CASE 5A.3: brace list open | |
5919 ((save-excursion | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5920 (c-beginning-of-decl-1 lim) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5921 (while (looking-at c-specifier-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5922 (goto-char (match-end 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5923 (c-forward-syntactic-ws indent-point)) |
18720 | 5924 (setq placeholder (c-point 'boi)) |
24282 | 5925 (or (consp special-brace-list) |
36920 | 5926 (and (or (save-excursion |
24282 | 5927 (goto-char indent-point) |
36920 | 5928 (setq tmpsymbol nil) |
24282 | 5929 (while (and (> (point) placeholder) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5930 (zerop (c-backward-token-2 1 t)) |
36920 | 5931 (/= (char-after) ?=)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5932 (and c-opt-inexpr-brace-list-key |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5933 (not tmpsymbol) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5934 (looking-at c-opt-inexpr-brace-list-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5935 (setq tmpsymbol 'topmost-intro-cont))) |
36920 | 5936 (eq (char-after) ?=)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5937 (looking-at c-brace-list-key)) |
21106
5e5fa0a34cb0
(c-inside-bracelist-p): Fix for enum test.
Richard M. Stallman <rms@gnu.org>
parents:
20914
diff
changeset
|
5938 (save-excursion |
24282 | 5939 (while (and (< (point) indent-point) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5940 (zerop (c-forward-token-2 1 t)) |
24282 | 5941 (not (memq (char-after) '(?\; ?\())))) |
5942 (not (memq (char-after) '(?\; ?\())) | |
5943 )))) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5944 (if (and (not c-auto-newline-analysis) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5945 (c-major-mode-is 'java-mode) |
36920 | 5946 (eq tmpsymbol 'topmost-intro-cont)) |
5947 ;; We're in Java and have found that the open brace | |
5948 ;; belongs to a "new Foo[]" initialization list, | |
5949 ;; which means the brace list is part of an | |
5950 ;; expression and not a top level definition. We | |
5951 ;; therefore treat it as any topmost continuation | |
5952 ;; even though the semantically correct symbol still | |
5953 ;; is brace-list-open, on the same grounds as in | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5954 ;; case B.2. |
36920 | 5955 (progn |
5956 (c-beginning-of-statement-1 lim) | |
5957 (c-add-syntax 'topmost-intro-cont (c-point 'boi))) | |
5958 (c-add-syntax 'brace-list-open placeholder))) | |
18720 | 5959 ;; 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
|
5960 ((and inclass-p (not inenclosing-p)) |
18720 | 5961 (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
|
5962 (c-add-class-syntax 'inclass inclass-p paren-state)) |
18720 | 5963 ;; CASE 5A.5: ordinary defun open |
5964 (t | |
5965 (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
|
5966 (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
|
5967 (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
|
5968 ;; 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
|
5969 (c-add-syntax 'defun-open (c-point 'bol))) |
18720 | 5970 ))) |
5971 ;; CASE 5B: first K&R arg decl or member init | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
5972 ((c-just-after-func-arglist-p lim) |
18720 | 5973 (cond |
5974 ;; CASE 5B.1: a member init | |
5975 ((or (eq char-before-ip ?:) | |
5976 (eq char-after-ip ?:)) | |
5977 ;; this line should be indented relative to the beginning | |
5978 ;; of indentation for the topmost-intro line that contains | |
5979 ;; the prototype's open paren | |
5980 ;; TBD: is the following redundant? | |
5981 (if (eq char-before-ip ?:) | |
5982 (forward-char -1)) | |
5983 (c-backward-syntactic-ws lim) | |
5984 ;; TBD: is the preceding redundant? | |
5985 (if (eq (char-before) ?:) | |
5986 (progn (forward-char -1) | |
5987 (c-backward-syntactic-ws lim))) | |
5988 (if (eq (char-before) ?\)) | |
24282 | 5989 (c-backward-sexp 1)) |
18720 | 5990 (setq placeholder (point)) |
5991 (save-excursion | |
24282 | 5992 (and (c-safe (c-backward-sexp 1) t) |
18720 | 5993 (looking-at "throw[^_]") |
24282 | 5994 (c-safe (c-backward-sexp 1) t) |
18720 | 5995 (setq placeholder (point)))) |
5996 (goto-char placeholder) | |
5997 (c-add-syntax 'member-init-intro (c-point 'boi)) | |
5998 ;; we don't need to add any class offset since this | |
5999 ;; should be relative to the ctor's indentation | |
6000 ) | |
6001 ;; CASE 5B.2: K&R arg decl intro | |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6002 ((and c-recognize-knr-p |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6003 (c-in-knr-argdecl lim)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6004 (c-beginning-of-statement-1 lim) |
18720 | 6005 (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
|
6006 (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
|
6007 (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
|
6008 ;; 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
|
6009 ((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
|
6010 (c-forward-syntactic-ws) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6011 (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
|
6012 ;; CASE 5B.4: Nether region after a C++ or Java func |
18720 | 6013 ;; decl, which could include a `throws' declaration. |
6014 (t | |
6015 (c-beginning-of-statement-1 lim) | |
6016 (c-add-syntax 'func-decl-cont (c-point 'boi)) | |
6017 ))) | |
6018 ;; CASE 5C: inheritance line. could be first inheritance | |
6019 ;; 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
|
6020 ((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
|
6021 (progn |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6022 (when (eq char-after-ip ?,) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6023 (skip-chars-forward " \t") |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6024 (forward-char)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6025 (looking-at c-opt-postfix-decl-spec-key))) |
18720 | 6026 (and (or (eq char-before-ip ?:) |
6027 ;; watch out for scope operator | |
6028 (save-excursion | |
6029 (and (eq char-after-ip ?:) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6030 (c-safe (forward-char 1) t) |
18720 | 6031 (not (eq (char-after) ?:)) |
6032 ))) | |
6033 (save-excursion | |
6034 (c-backward-syntactic-ws lim) | |
6035 (if (eq char-before-ip ?:) | |
6036 (progn | |
6037 (forward-char -1) | |
6038 (c-backward-syntactic-ws lim))) | |
6039 (back-to-indentation) | |
6040 (looking-at c-class-key))) | |
6041 ;; for Java | |
24282 | 6042 (and (c-major-mode-is 'java-mode) |
18720 | 6043 (let ((fence (save-excursion |
6044 (c-beginning-of-statement-1 lim) | |
6045 (point))) | |
6046 cont done) | |
6047 (save-excursion | |
6048 (while (not done) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6049 (cond ((looking-at c-opt-postfix-decl-spec-key) |
18720 | 6050 (setq injava-inher (cons cont (point)) |
6051 done t)) | |
24282 | 6052 ((or (not (c-safe (c-forward-sexp -1) t)) |
18720 | 6053 (<= (point) fence)) |
6054 (setq done t)) | |
6055 ) | |
6056 (setq cont t))) | |
6057 injava-inher) | |
6058 (not (c-crosses-statement-barrier-p (cdr injava-inher) | |
6059 (point))) | |
6060 )) | |
6061 (cond | |
6062 ;; CASE 5C.1: non-hanging colon on an inher intro | |
6063 ((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
|
6064 (c-beginning-of-statement-1 lim) |
18720 | 6065 (c-add-syntax 'inher-intro (c-point 'boi)) |
6066 ;; don't add inclass symbol since relative point already | |
6067 ;; contains any class offset | |
6068 ) | |
6069 ;; CASE 5C.2: hanging colon on an inher intro | |
6070 ((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
|
6071 (c-beginning-of-statement-1 lim) |
18720 | 6072 (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
|
6073 (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
|
6074 (c-add-class-syntax 'inclass inclass-p paren-state))) |
18720 | 6075 ;; CASE 5C.3: in a Java implements/extends |
6076 (injava-inher | |
6077 (let ((where (cdr injava-inher)) | |
6078 (cont (car injava-inher))) | |
6079 (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
|
6080 (cond ((looking-at "throws\\>[^_]") |
18720 | 6081 (c-add-syntax 'func-decl-cont |
6082 (progn (c-beginning-of-statement-1 lim) | |
6083 (c-point 'boi)))) | |
6084 (cont (c-add-syntax 'inher-cont where)) | |
6085 (t (c-add-syntax 'inher-intro | |
6086 (progn (goto-char (cdr injava-inher)) | |
6087 (c-beginning-of-statement-1 lim) | |
6088 (point)))) | |
6089 ))) | |
6090 ;; CASE 5C.4: a continued inheritance line | |
6091 (t | |
6092 (c-beginning-of-inheritance-list lim) | |
6093 (c-add-syntax 'inher-cont (point)) | |
6094 ;; don't add inclass symbol since relative point already | |
6095 ;; contains any class offset | |
6096 ))) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6097 ;; CASE 5D: this could be a top-level initialization, a |
26817 | 6098 ;; member init list continuation, or a template argument |
6099 ;; list continuation. | |
6100 ((c-with-syntax-table (if (c-major-mode-is 'c++-mode) | |
6101 c++-template-syntax-table | |
6102 (syntax-table)) | |
6103 (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
|
6104 ;; 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
|
6105 ;; preceding brace sexp. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6106 (while (and (zerop (c-backward-token-2 1 t lim)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6107 (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
|
6108 (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
|
6109 (and (c-major-mode-is 'c++-mode) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6110 (zerop (c-backward-token-2 1 nil 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
|
6111 (eq (char-after) ?<))))) |
18720 | 6112 (goto-char indent-point) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6113 (setq placeholder |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6114 (c-beginning-of-member-init-list lim)) |
18720 | 6115 (cond |
6116 ;; CASE 5D.1: hanging member init colon, but watch out | |
6117 ;; for bogus matches on access specifiers inside classes. | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6118 ((and placeholder |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6119 (save-excursion |
24282 | 6120 (setq placeholder (point)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6121 (c-backward-token-2 1 t lim) |
26817 | 6122 (and (eq (char-after) ?:) |
6123 (not (eq (char-before) ?:)))) | |
18720 | 6124 (save-excursion |
24282 | 6125 (goto-char placeholder) |
6126 (back-to-indentation) | |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6127 (or |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6128 (/= (car (save-excursion |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6129 (parse-partial-sexp (point) placeholder))) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6130 0) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6131 (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
|
6132 (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
|
6133 (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
|
6134 (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
|
6135 (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
|
6136 (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
|
6137 ))) |
24282 | 6138 (goto-char placeholder) |
6139 (c-forward-syntactic-ws) | |
6140 (c-add-syntax 'member-init-cont (point)) | |
18720 | 6141 ;; we do not need to add class offset since relative |
6142 ;; point is the member init above us | |
6143 ) | |
6144 ;; CASE 5D.2: non-hanging member init colon | |
6145 ((progn | |
6146 (c-forward-syntactic-ws indent-point) | |
6147 (eq (char-after) ?:)) | |
6148 (skip-chars-forward " \t:") | |
6149 (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
|
6150 ;; 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
|
6151 ((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
|
6152 (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
|
6153 (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
|
6154 (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
|
6155 (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
|
6156 (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
|
6157 (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
|
6158 (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
|
6159 ;; 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
|
6160 (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
|
6161 (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
|
6162 (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
|
6163 ;; 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
|
6164 ((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
|
6165 (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
|
6166 (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
|
6167 (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
|
6168 (if (looking-at "static\\>[^_]") |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6169 (c-forward-token-2 1 nil indent-point)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6170 (and (looking-at c-class-key) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6171 (zerop (c-forward-token-2 2 nil indent-point)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6172 (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
|
6173 (c-with-syntax-table c++-template-syntax-table |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6174 (zerop (c-forward-token-2 1 t indent-point))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6175 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
|
6176 (eq (char-after) ?:)))) |
24282 | 6177 (goto-char placeholder) |
18720 | 6178 (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
|
6179 ;; 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
|
6180 ;; top level construct. |
18720 | 6181 (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
|
6182 (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
|
6183 '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
|
6184 (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
|
6185 (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
|
6186 (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
|
6187 (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
|
6188 (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
|
6189 ;; 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
|
6190 ;; 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
|
6191 ;; 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
|
6192 ;; 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
|
6193 '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
|
6194 'statement-cont) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6195 nil nil nil containing-sexp paren-state)) |
18720 | 6196 )) |
6197 ;; CASE 5E: we are looking at a access specifier | |
6198 ((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
|
6199 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
|
6200 (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
|
6201 (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
|
6202 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
|
6203 ;; Append access-label with the same anchor point as inclass gets. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6204 (c-append-syntax 'access-label placeholder)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6205 ;; CASE 5F: Close of a non-class declaration level block. |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
6206 ((and inenclosing-p |
18720 | 6207 (eq char-after-ip ?})) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6208 (c-add-syntax (intern (concat inenclosing-p "-close")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6209 (aref inclass-p 0))) |
18720 | 6210 ;; CASE 5G: we are looking at the brace which closes the |
6211 ;; enclosing nested class decl | |
6212 ((and inclass-p | |
6213 (eq char-after-ip ?}) | |
6214 (save-excursion | |
6215 (save-restriction | |
6216 (widen) | |
6217 (forward-char 1) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6218 (and (c-safe (c-backward-sexp 1) t) |
24282 | 6219 (= (point) (aref inclass-p 1)) |
6220 )))) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6221 (c-add-class-syntax 'class-close inclass-p paren-state)) |
18720 | 6222 ;; CASE 5H: we could be looking at subsequent knr-argdecls |
6223 ((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
|
6224 (not (eq char-before-ip ?})) |
18720 | 6225 (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
|
6226 (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
|
6227 (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
|
6228 ;; 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
|
6229 ;; 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
|
6230 ;; (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
|
6231 ;; 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
|
6232 (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
|
6233 (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
|
6234 (< placeholder indent-point)) |
18720 | 6235 (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
|
6236 (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
|
6237 ;; 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
|
6238 ((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
|
6239 (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
|
6240 (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
|
6241 (c-add-syntax 'objc-method-intro (c-point 'boi))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6242 ;; CASE 5P: AWK pattern or function or continuation |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6243 ;; thereof. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6244 ((c-mode-is-new-awk-p) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6245 (setq placeholder (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6246 (c-add-stmt-syntax |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6247 (if (and (eq (c-beginning-of-statement-1) 'same) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6248 (/= (point) placeholder)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6249 'topmost-intro-cont |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6250 'topmost-intro) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6251 nil nil nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6252 containing-sexp paren-state)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6253 ;; 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
|
6254 ;; 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
|
6255 ;; end at the closing '}'. C.f. case 5D.5. |
18720 | 6256 ((progn |
6257 (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
|
6258 (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
|
6259 (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
|
6260 (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
|
6261 (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
|
6262 ;; 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
|
6263 (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
|
6264 (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
|
6265 (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
|
6266 (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
|
6267 ;; 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
|
6268 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
|
6269 (c-end-of-decl-1) |
52107
3a5379a0d7f3
2003-08-01 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51947
diff
changeset
|
6270 (>= (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
|
6271 (goto-char placeholder) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6272 (c-add-stmt-syntax 'topmost-intro-cont nil nil nil |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6273 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
|
6274 ;; 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
|
6275 ;; 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
|
6276 ((progn |
18720 | 6277 (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
|
6278 c-opt-access-key |
18720 | 6279 (not (bobp)) |
6280 (save-excursion | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6281 (c-safe (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
|
6282 (looking-at c-opt-access-key))) |
24282 | 6283 (c-backward-sexp 1) |
18720 | 6284 (c-backward-syntactic-ws lim)) |
6285 (or (bobp) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6286 (if (c-mode-is-new-awk-p) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6287 (not (c-awk-prev-line-incomplete-p)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6288 (memq (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
|
6289 (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
|
6290 (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
|
6291 (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
|
6292 (eq (char-after) ?@))))) |
18720 | 6293 ;; real beginning-of-line could be narrowed out due to |
6294 ;; enclosure in a class block | |
6295 (save-restriction | |
6296 (widen) | |
6297 (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
|
6298 ;; 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
|
6299 ;; it makes our lives hard to remain compatible. :P |
18720 | 6300 (if inclass-p |
6301 (progn | |
6302 (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
|
6303 (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
|
6304 (goto-char (aref inclass-p 0))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6305 (if inenclosing-p |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6306 (c-add-syntax (intern (concat "in" inenclosing-p)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6307 (c-point 'boi)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6308 (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
|
6309 )) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6310 (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
|
6311 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
|
6312 (/= 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
|
6313 (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
|
6314 (setq macro-start nil)) |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
6315 )) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6316 ;; CASE 5K: we are at an ObjC method definition |
18720 | 6317 ;; 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
|
6318 ((and c-opt-method-key |
18720 | 6319 (progn |
6320 (c-beginning-of-statement-1 lim) | |
6321 (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
|
6322 (looking-at c-opt-method-key))) |
18720 | 6323 (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
|
6324 ;; CASE 5L: we are at the first argument of a template |
26817 | 6325 ;; arglist that begins on the previous line. |
6326 ((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
|
6327 (c-beginning-of-statement-1 (c-safe-position (point) paren-state)) |
26817 | 6328 (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
|
6329 ;; CASE 5M: we are at a topmost continuation line |
18720 | 6330 (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
|
6331 (c-beginning-of-statement-1 (c-safe-position (point) paren-state)) |
18720 | 6332 (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
|
6333 )) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6334 ;; (CASE 6 has been removed.) |
24282 | 6335 ;; CASE 7: line is an expression, not a statement. Most |
18720 | 6336 ;; likely we are either in a function prototype or a function |
6337 ;; call argument list | |
24282 | 6338 ((not (or (and c-special-brace-lists |
6339 (save-excursion | |
6340 (goto-char containing-sexp) | |
6341 (c-looking-at-special-brace-list))) | |
6342 (eq (char-after containing-sexp) ?{))) | |
18720 | 6343 (cond |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6344 ;; CASE 7A: we are looking at the arglist closing paren. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6345 ;; C.f. case 7F. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6346 ((memq char-after-ip '(?\) ?\])) |
18720 | 6347 (goto-char containing-sexp) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6348 (setq placeholder (c-point 'boi)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6349 (if (and (c-safe (backward-up-list 1) t) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
6350 (>= (point) placeholder)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6351 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6352 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6353 (skip-chars-forward " \t")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6354 (goto-char placeholder)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6355 (c-add-stmt-syntax 'arglist-close (list containing-sexp) t nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6356 (c-most-enclosing-brace paren-state (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6357 (c-whack-state-after (point) paren-state))) |
24282 | 6358 ;; 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
|
6359 ;; 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
|
6360 ;; 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
|
6361 ((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
|
6362 (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
|
6363 (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
|
6364 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
|
6365 (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
|
6366 (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
|
6367 (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
|
6368 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
|
6369 (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
|
6370 (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
|
6371 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
|
6372 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
|
6373 ;; 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
|
6374 ;; 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
|
6375 ;; 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
|
6376 ))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6377 (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
|
6378 (back-to-indentation) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6379 (c-add-stmt-syntax (car tmpsymbol) nil t 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
|
6380 (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
|
6381 (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
|
6382 (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
|
6383 (c-add-syntax (cdr tmpsymbol)))) |
24282 | 6384 ;; CASE 7C: we are looking at the first argument in an empty |
18720 | 6385 ;; argument list. Use arglist-close if we're actually |
6386 ;; looking at a close paren or bracket. | |
6387 ((memq char-before-ip '(?\( ?\[)) | |
6388 (goto-char containing-sexp) | |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6389 (setq placeholder (c-point 'boi)) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6390 (when (and (c-safe (backward-up-list 1) t) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
6391 (>= (point) placeholder)) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6392 (forward-char) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6393 (skip-chars-forward " \t") |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6394 (setq placeholder (point))) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6395 (c-add-syntax 'arglist-intro placeholder)) |
24282 | 6396 ;; CASE 7D: we are inside a conditional test clause. treat |
18720 | 6397 ;; 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
|
6398 ((progn |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
6399 (goto-char containing-sexp) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6400 (and (c-safe (c-forward-sexp -1) t) |
20914
8f189ffad604
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Richard M. Stallman <rms@gnu.org>
parents:
20142
diff
changeset
|
6401 (looking-at "\\<for\\>[^_]"))) |
18720 | 6402 (goto-char (1+ containing-sexp)) |
6403 (c-forward-syntactic-ws indent-point) | |
6404 (if (eq char-before-ip ?\;) | |
6405 (c-add-syntax 'statement (point)) | |
6406 (c-add-syntax 'statement-cont (point)) | |
6407 )) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6408 ;; 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
|
6409 ;; 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
|
6410 ;; 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
|
6411 ((and c-opt-method-key |
18720 | 6412 (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
|
6413 (progn |
18720 | 6414 (goto-char (1- containing-sexp)) |
6415 (c-backward-syntactic-ws (c-point 'bod)) | |
6416 (if (not (looking-at c-symbol-key)) | |
6417 (c-add-syntax 'objc-method-call-cont containing-sexp)) | |
6418 ))) | |
24282 | 6419 ;; CASE 7F: we are looking at an arglist continuation line, |
18720 | 6420 ;; but the preceding argument is on the same line as the |
6421 ;; opening paren. This case includes multi-line | |
6422 ;; mathematical paren groupings, but we could be on a | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6423 ;; for-list continuation line. C.f. case 7A. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6424 ((progn |
36920 | 6425 (goto-char (1+ containing-sexp)) |
6426 (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
|
6427 (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
|
6428 (not (looking-at "\\\\$")))) |
18720 | 6429 (goto-char containing-sexp) |
30403
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6430 (setq placeholder (c-point 'boi)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6431 (if (and (c-safe (backward-up-list 1) t) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
6432 (>= (point) placeholder)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6433 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6434 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6435 (skip-chars-forward " \t")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6436 (goto-char placeholder)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6437 (c-add-stmt-syntax 'arglist-cont-nonempty (list containing-sexp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6438 t nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6439 (c-most-enclosing-brace c-state-cache (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6440 (c-whack-state-after (point) paren-state))) |
24282 | 6441 ;; CASE 7G: we are looking at just a normal arglist |
18720 | 6442 ;; 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
|
6443 (t (c-forward-syntactic-ws indent-point) |
18720 | 6444 (c-add-syntax 'arglist-cont (c-point 'boi))) |
6445 )) | |
24282 | 6446 ;; 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
|
6447 ((and (c-major-mode-is 'c++-mode) |
18720 | 6448 (save-excursion |
6449 (goto-char indent-point) | |
6450 (skip-chars-forward " \t") | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6451 (looking-at c-opt-postfix-decl-spec-key))) |
18720 | 6452 (goto-char indent-point) |
6453 (skip-chars-forward " \t") | |
6454 (cond | |
24282 | 6455 ;; CASE 8A: non-hanging colon on an inher intro |
18720 | 6456 ((eq char-after-ip ?:) |
6457 (c-backward-syntactic-ws lim) | |
6458 (c-add-syntax 'inher-intro (c-point 'boi))) | |
24282 | 6459 ;; CASE 8B: hanging colon on an inher intro |
18720 | 6460 ((eq char-before-ip ?:) |
6461 (c-add-syntax 'inher-intro (c-point 'boi))) | |
24282 | 6462 ;; CASE 8C: a continued inheritance line |
18720 | 6463 (t |
6464 (c-beginning-of-inheritance-list lim) | |
6465 (c-add-syntax 'inher-cont (point)) | |
6466 ))) | |
24282 | 6467 ;; CASE 9: we are inside a brace-list |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6468 ((and (not (c-mode-is-new-awk-p)) ; Maybe this isn't needed (ACM, 2002/3/29) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6469 (setq special-brace-list |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6470 (or (and c-special-brace-lists |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6471 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6472 (goto-char containing-sexp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6473 (c-looking-at-special-brace-list))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6474 (c-inside-bracelist-p containing-sexp paren-state)))) |
18720 | 6475 (cond |
24282 | 6476 ;; CASE 9A: In the middle of a special brace list opener. |
6477 ((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
|
6478 (save-excursion |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6479 (goto-char containing-sexp) |
68e734ab7d5d
(c-looking-at-inexpr-block): Replaced a call to
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
6480 (eq (char-after) ?\()) |
24282 | 6481 (eq char-after-ip (car (cdr special-brace-list)))) |
6482 (goto-char (car (car special-brace-list))) | |
26817 | 6483 (skip-chars-backward " \t") |
36920 | 6484 (if (and (bolp) |
6485 (assoc 'statement-cont | |
6486 (setq placeholder (c-guess-basic-syntax)))) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6487 (setq c-syntactic-context placeholder) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6488 (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
|
6489 (c-safe-position (1- containing-sexp) paren-state)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6490 (c-forward-token-2 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6491 (while (looking-at c-specifier-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6492 (goto-char (match-end 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6493 (c-forward-syntactic-ws)) |
26817 | 6494 (c-add-syntax 'brace-list-open (c-point 'boi)))) |
24282 | 6495 ;; CASE 9B: brace-list-close brace |
6496 ((if (consp special-brace-list) | |
6497 ;; Check special brace list closer. | |
6498 (progn | |
6499 (goto-char (car (car special-brace-list))) | |
6500 (save-excursion | |
6501 (goto-char indent-point) | |
6502 (back-to-indentation) | |
6503 (or | |
6504 ;; We were between the special close char and the `)'. | |
6505 (and (eq (char-after) ?\)) | |
6506 (eq (1+ (point)) (cdr (car special-brace-list)))) | |
6507 ;; We were before the special close char. | |
6508 (and (eq (char-after) (cdr (cdr special-brace-list))) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6509 (zerop (c-forward-token-2)) |
24282 | 6510 (eq (1+ (point)) (cdr (car special-brace-list))))))) |
6511 ;; Normal brace list check. | |
6512 (and (eq char-after-ip ?}) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6513 (c-safe (goto-char (c-up-list-backward (point))) t) |
24282 | 6514 (= (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
|
6515 (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
|
6516 (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
|
6517 (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
|
6518 (c-beginning-of-statement-1 lim) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6519 (c-add-stmt-syntax 'brace-list-close nil t t lim |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6520 (c-whack-state-after (point) paren-state)))) |
24282 | 6521 (t |
6522 ;; Prepare for the rest of the cases below by going to the | |
6523 ;; token following the opening brace | |
6524 (if (consp special-brace-list) | |
6525 (progn | |
6526 (goto-char (car (car special-brace-list))) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6527 (c-forward-token-2 1 nil indent-point)) |
24282 | 6528 (goto-char containing-sexp)) |
6529 (forward-char) | |
6530 (let ((start (point))) | |
18720 | 6531 (c-forward-syntactic-ws indent-point) |
24282 | 6532 (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
|
6533 (c-skip-ws-forward indent-point) |
24282 | 6534 (cond |
6535 ;; CASE 9C: we're looking at the first line in a brace-list | |
6536 ((= (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
|
6537 (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
|
6538 (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
|
6539 (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
|
6540 (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
|
6541 (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
|
6542 (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
|
6543 (c-beginning-of-statement-1 lim) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6544 (c-add-stmt-syntax 'brace-list-intro nil t t lim |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6545 (c-whack-state-after (point) paren-state)))) |
24282 | 6546 ;; CASE 9D: this is just a later brace-list-entry or |
36920 | 6547 ;; brace-entry-open |
24282 | 6548 (t (if (or (eq char-after-ip ?{) |
6549 (and c-special-brace-lists | |
6550 (save-excursion | |
6551 (goto-char indent-point) | |
6552 (c-forward-syntactic-ws (c-point 'eol)) | |
6553 (c-looking-at-special-brace-list (point))))) | |
6554 (c-add-syntax 'brace-entry-open (point)) | |
6555 (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
|
6556 )) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6557 )))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6558 ;; CASE 10: A continued statement or top level construct. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6559 ((and (if (c-mode-is-new-awk-p) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6560 (c-awk-prev-line-incomplete-p containing-sexp) ; ACM 2002/3/29 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6561 (and (not (memq char-before-ip '(?\; ?:))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6562 (or (not (eq char-before-ip ?})) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6563 (c-looking-at-inexpr-block-backward c-state-cache)))) |
18720 | 6564 (> (point) |
6565 (save-excursion | |
6566 (c-beginning-of-statement-1 containing-sexp) | |
6567 (setq placeholder (point)))) | |
6568 (/= 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
|
6569 ;; 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
|
6570 (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
|
6571 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
|
6572 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
|
6573 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
|
6574 paren-state)) |
24282 | 6575 ;; 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
|
6576 ((looking-at c-label-kwds-regexp) |
18720 | 6577 (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
|
6578 (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
|
6579 (c-backward-to-block-anchor lim) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6580 (c-add-stmt-syntax 'case-label nil t nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6581 lim paren-state)) |
24282 | 6582 ;; CASE 15: any other label |
18720 | 6583 ((looking-at c-label-key) |
6584 (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
|
6585 (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
|
6586 (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
|
6587 (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
|
6588 (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
|
6589 (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
|
6590 ;; 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
|
6591 ;; 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
|
6592 ;; 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
|
6593 '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
|
6594 '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
|
6595 (c-backward-to-block-anchor lim) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6596 (c-add-stmt-syntax tmpsymbol nil t nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6597 lim paren-state)) |
24282 | 6598 ;; CASE 16: block close brace, possibly closing the defun or |
18720 | 6599 ;; the class |
6600 ((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
|
6601 ;; 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
|
6602 (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
|
6603 (goto-char containing-sexp) |
18720 | 6604 (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
|
6605 ;; 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
|
6606 ;; 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
|
6607 ;; 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
|
6608 ;; 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
|
6609 ((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
|
6610 (c-backward-to-block-anchor lim) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6611 (c-add-stmt-syntax 'block-close nil t nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6612 lim paren-state)) |
24282 | 6613 ;; 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
|
6614 ;; 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
|
6615 ((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
|
6616 (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
|
6617 nil)) |
24282 | 6618 (setq tmpsymbol (if (eq (car placeholder) 'inlambda) |
6619 'inline-close | |
6620 'block-close)) | |
6621 (goto-char containing-sexp) | |
6622 (back-to-indentation) | |
6623 (if (= containing-sexp (point)) | |
6624 (c-add-syntax tmpsymbol (point)) | |
6625 (goto-char (cdr placeholder)) | |
36920 | 6626 (back-to-indentation) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6627 (c-add-stmt-syntax tmpsymbol nil t 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
|
6628 (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
|
6629 (c-whack-state-after (point) paren-state)) |
36920 | 6630 (if (/= (point) (cdr placeholder)) |
6631 (c-add-syntax (car placeholder))))) | |
24282 | 6632 ;; CASE 16B: does this close an inline or a function in |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6633 ;; a non-class declaration level 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
|
6634 ((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
|
6635 (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
|
6636 (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
|
6637 (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
|
6638 (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
|
6639 (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
|
6640 (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
|
6641 (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
|
6642 ;; 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
|
6643 ;; in a statement block, e.g. in Pike or when using gcc |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6644 ;; extensions, but watch out for macros followed by |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6645 ;; blocks. Let it through to be handled below. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6646 ;; 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
|
6647 ((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
|
6648 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
|
6649 (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
|
6650 (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
|
6651 (eq (c-beginning-of-statement-1 lim nil nil t) 'same) |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6652 (setq placeholder (point)) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6653 ;; Look for a type or identifier followed by a |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6654 ;; symbol, i.e. the start of a function declaration. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6655 ;; Doesn't work for declarations like "int *foo() |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6656 ;; ..."; we'd need to refactor the more competent |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6657 ;; analysis in `c-font-lock-declarations' for that. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6658 (c-forward-type) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6659 (progn |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6660 (c-forward-syntactic-ws) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6661 (looking-at c-symbol-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
|
6662 (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
|
6663 (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
|
6664 (goto-char placeholder)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6665 (c-add-stmt-syntax 'defun-close nil t nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6666 lim paren-state)) |
24282 | 6667 ;; CASE 16C: if there an enclosing brace that hasn't |
18720 | 6668 ;; 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
|
6669 ;; 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
|
6670 ((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
|
6671 ;; 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
|
6672 ;; 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
|
6673 ;; 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
|
6674 ;; 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
|
6675 ;; 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
|
6676 ;; 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
|
6677 (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
|
6678 (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
|
6679 (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
|
6680 (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
|
6681 (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
|
6682 (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
|
6683 ;; 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
|
6684 ;; situations are handled in case 16E above. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6685 (c-add-stmt-syntax 'block-close nil t nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6686 lim paren-state))) |
24282 | 6687 ;; CASE 16D: find out whether we're closing a top-level |
18720 | 6688 ;; class or a defun |
6689 (t | |
6690 (save-restriction | |
6691 (narrow-to-region (point-min) indent-point) | |
6692 (let ((decl (c-search-uplist-for-classkey (c-parse-state)))) | |
6693 (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
|
6694 (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
|
6695 (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
|
6696 (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
|
6697 (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
|
6698 (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
|
6699 ))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6700 ;; CASE 17: Statement or defun catchall. |
18720 | 6701 (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
|
6702 (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
|
6703 ;; 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
|
6704 (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
|
6705 (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
|
6706 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
|
6707 (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
|
6708 (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
|
6709 (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
|
6710 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
|
6711 (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
|
6712 (/= (point) (c-point 'boi))))) |
18720 | 6713 (cond |
24282 | 6714 ;; 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
|
6715 ((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
|
6716 (/= (point) indent-point)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6717 (c-add-stmt-syntax 'statement-cont nil nil nil |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6718 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
|
6719 ;; 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
|
6720 ((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
|
6721 (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
|
6722 (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
|
6723 (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
|
6724 (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
|
6725 (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
|
6726 (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
|
6727 '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
|
6728 'statement-case-intro) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6729 nil t nil containing-sexp paren-state)) |
24282 | 6730 ;; 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
|
6731 ((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
|
6732 (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
|
6733 (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
|
6734 (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
|
6735 (eq step-type 'previous)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6736 (c-add-stmt-syntax 'statement nil t nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6737 containing-sexp paren-state) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6738 (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
|
6739 (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
|
6740 ;; 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
|
6741 ((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
|
6742 ;; 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
|
6743 (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
|
6744 ;; 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
|
6745 (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
|
6746 (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
|
6747 (c-backward-to-block-anchor lim) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6748 (c-add-stmt-syntax 'statement-block-intro nil t nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6749 lim paren-state) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6750 (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
|
6751 (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
|
6752 ;; 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
|
6753 ;; 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
|
6754 ((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
|
6755 (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
|
6756 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
|
6757 (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
|
6758 '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
|
6759 'statement-block-intro)) |
24282 | 6760 (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
|
6761 (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
|
6762 (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
|
6763 (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
|
6764 (back-to-indentation) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6765 (c-add-stmt-syntax tmpsymbol nil t 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
|
6766 (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
|
6767 (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
|
6768 (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
|
6769 (c-add-syntax (car placeholder)))) |
24282 | 6770 (if (eq char-after-ip ?{) |
6771 (c-add-syntax 'block-open))) | |
6772 ;; CASE 17F: first statement in an inline, or first | |
18720 | 6773 ;; statement in a top-level defun. we can tell this is it |
6774 ;; 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
|
6775 ;; narrowed out by a class (i.e. don't use bod here). |
18720 | 6776 ((save-excursion |
6777 (save-restriction | |
6778 (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
|
6779 (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
|
6780 (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
|
6781 (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
|
6782 (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
|
6783 (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
|
6784 ;; 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
|
6785 ;; a normal block. This can occur in Pike and with |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6786 ;; e.g. the gcc extensions, but watch out for macros |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6787 ;; followed by blocks. C.f. cases B.3 and 16F. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6788 ((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
|
6789 (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
|
6790 (eq (c-beginning-of-statement-1 lim nil nil t) 'same) |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6791 (setq placeholder (point)) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6792 ;; Look for a type or identifier followed by a |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6793 ;; symbol, i.e. the start of a function declaration. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6794 ;; Doesn't work for declarations like "int *foo() |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6795 ;; ..."; we'd need to refactor the more competent |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6796 ;; analysis in `c-font-lock-declarations' for that. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6797 (c-forward-type) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6798 (progn |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6799 (c-forward-syntactic-ws) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52605
diff
changeset
|
6800 (looking-at c-symbol-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
|
6801 (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
|
6802 (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
|
6803 (goto-char placeholder)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6804 (c-add-stmt-syntax 'defun-block-intro nil t nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6805 lim paren-state)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6806 ;; 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
|
6807 (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
|
6808 ;; 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
|
6809 ;; 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
|
6810 ;; 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
|
6811 ;; 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
|
6812 ;; 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
|
6813 (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
|
6814 (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
|
6815 (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
|
6816 (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
|
6817 (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
|
6818 (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
|
6819 ;; 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
|
6820 ;; situations are handled in case 17I above. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6821 (c-add-stmt-syntax 'statement-block-intro nil t nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6822 lim paren-state)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6823 (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
|
6824 (c-add-syntax 'block-open))) |
18720 | 6825 )) |
6826 ) | |
6827 ;; now we need to look at any modifiers | |
6828 (goto-char indent-point) | |
6829 (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
|
6830 ;; 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
|
6831 (when (and (looking-at c-comment-start-regexp) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6832 (/= (c-forward-token-2 0 nil (c-point 'eol)) 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6833 (c-append-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
|
6834 ;; 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
|
6835 (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
|
6836 (looking-at c-opt-friend-key)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6837 (c-append-syntax 'friend)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6838 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6839 ;; Set syntactic-relpos. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6840 (let ((p c-syntactic-context)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6841 (while (and p |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6842 (if (integerp (car-safe (cdr-safe (car p)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6843 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6844 (setq syntactic-relpos (car (cdr (car p)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6845 nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6846 t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6847 (setq p (cdr p)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6848 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6849 ;; 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
|
6850 (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
|
6851 (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
|
6852 (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
|
6853 (eq (char-after (1+ macro-start)) ?\")))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6854 (c-append-syntax 'cpp-macro) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6855 (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
|
6856 (if in-macro-expr |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6857 (when (or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6858 (< syntactic-relpos macro-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6859 (not (or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6860 (assq 'arglist-intro c-syntactic-context) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6861 (assq 'arglist-cont c-syntactic-context) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6862 (assq 'arglist-cont-nonempty c-syntactic-context) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6863 (assq 'arglist-close c-syntactic-context)))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6864 ;; 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
|
6865 ;; 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
|
6866 ;; 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
|
6867 ;; 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
|
6868 ;; 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
|
6869 ;; expression. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6870 (setq c-syntactic-context nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6871 (c-add-syntax 'cpp-macro-cont macro-start)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6872 (when (and (eq macro-start syntactic-relpos) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6873 (not (assq 'cpp-define-intro c-syntactic-context)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6874 (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
|
6875 (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
|
6876 (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
|
6877 (<= (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
|
6878 ;; 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
|
6879 ;; 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
|
6880 ;; 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
|
6881 ;; 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
|
6882 (c-add-syntax 'cpp-define-intro))))) |
18720 | 6883 ;; return the syntax |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6884 c-syntactic-context)))) |
18720 | 6885 |
6886 | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6887 ;; Indentation calculation. |
18720 | 6888 |
36920 | 6889 (defun c-evaluate-offset (offset langelem symbol) |
6890 ;; offset can be a number, a function, a variable, a list, or one of | |
6891 ;; the symbols + or - | |
6892 (cond | |
6893 ((eq offset '+) c-basic-offset) | |
6894 ((eq offset '-) (- c-basic-offset)) | |
6895 ((eq offset '++) (* 2 c-basic-offset)) | |
6896 ((eq offset '--) (* 2 (- c-basic-offset))) | |
6897 ((eq offset '*) (/ c-basic-offset 2)) | |
6898 ((eq offset '/) (/ (- c-basic-offset) 2)) | |
6899 ((numberp offset) offset) | |
6900 ((functionp offset) (c-evaluate-offset | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6901 (funcall offset |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6902 (cons (car langelem) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6903 (car-safe (cdr langelem)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6904 langelem symbol)) |
36920 | 6905 ((vectorp offset) offset) |
6906 ((null offset) nil) | |
6907 ((listp offset) | |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
6908 (if (eq (car offset) 'quote) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
6909 (error |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
6910 "Setting in c-offsets-alist element \"(%s . '%s)\" was mistakenly quoted" |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53073
diff
changeset
|
6911 symbol (cadr offset))) |
36920 | 6912 (let (done) |
6913 (while (and (not done) offset) | |
6914 (setq done (c-evaluate-offset (car offset) langelem symbol) | |
6915 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
|
6916 (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
|
6917 (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
|
6918 done)) |
36920 | 6919 (t (symbol-value offset)) |
6920 )) | |
6921 | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6922 (defun c-calc-offset (langelem) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6923 ;; Get offset from LANGELEM which is a list beginning with the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6924 ;; syntactic symbol and followed by any analysis data it provides. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6925 ;; That data may be zero or more elements, but if at least one is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6926 ;; given then the first is the relpos (or nil). The symbol is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6927 ;; matched against `c-offsets-alist' and the offset calculated from |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6928 ;; that is returned. |
36920 | 6929 (let* ((symbol (car langelem)) |
6930 (match (assq symbol c-offsets-alist)) | |
6931 (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
|
6932 (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
|
6933 (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
|
6934 (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
|
6935 (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
|
6936 (setq offset 0)) |
36920 | 6937 (if (vectorp offset) |
6938 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
|
6939 (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
|
6940 (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
|
6941 0)) |
36920 | 6942 )) |
6943 | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6944 (defun c-get-offset (langelem) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6945 ;; This is a compatibility wrapper for `c-calc-offset' in case |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6946 ;; someone is calling it directly. It takes an old style syntactic |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6947 ;; element on the form (SYMBOL . RELPOS) and converts it to the new |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6948 ;; list form. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6949 (if (cdr langelem) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6950 (c-calc-offset (list (car langelem) (cdr langelem))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6951 (c-calc-offset langelem))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6952 |
36920 | 6953 (defun c-get-syntactic-indentation (langelems) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6954 ;; Calculate the syntactic indentation from a syntactic description |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6955 ;; as returned by `c-guess-syntax'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6956 ;; |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
44510
diff
changeset
|
6957 ;; 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
|
6958 ;; 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
|
6959 ;; 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
|
6960 ;; 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
|
6961 ;; 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
|
6962 (let ((indent 0) anchor) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6963 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6964 (while langelems |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6965 (let* ((c-syntactic-element (car langelems)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6966 (res (c-calc-offset c-syntactic-element))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6967 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6968 (if (vectorp res) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6969 ;; Got an absolute column that overrides any indentation |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6970 ;; we've collected so far, but not the relative |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6971 ;; indentation we might get for the nested structures |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6972 ;; further down the langelems list. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6973 (setq indent (elt res 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6974 anchor (point-min)) ; A position at column 0. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6975 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6976 ;; Got a relative change of the current calculated |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6977 ;; indentation. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6978 (setq indent (+ indent res)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6979 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6980 ;; Use the anchor position from the first syntactic |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6981 ;; element with one. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6982 (unless anchor |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6983 (let ((relpos (car-safe (cdr (car langelems))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6984 (if relpos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6985 (setq anchor relpos))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6986 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6987 (setq langelems (cdr langelems)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6988 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6989 (if anchor |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6990 (+ indent (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6991 (goto-char anchor) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6992 (current-column))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
50273
diff
changeset
|
6993 indent))) |
26817 | 6994 |
18720 | 6995 |
36920 | 6996 (cc-provide 'cc-engine) |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
6997 |
52401 | 6998 ;;; arch-tag: 149add18-4673-4da5-ac47-6805e4eae089 |
18720 | 6999 ;;; cc-engine.el ends here |