aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-02-17 07:08:44 +0000
committerRichard M. Stallman1998-02-17 07:08:44 +0000
commite1c458ae0833358eafc4067ddfca1a96652104ef (patch)
tree6f353e9afe07d746b06c150e603e914369f69fc1
parentd5436a295ebecaee604c27d007c4566d067ed975 (diff)
downloademacs-e1c458ae0833358eafc4067ddfca1a96652104ef.tar.gz
emacs-e1c458ae0833358eafc4067ddfca1a96652104ef.zip
(c-forward-syntactic-ws, c-backward-syntactic-ws):
Don't narrow, just make a simple check against the given limit. (c-collect-line-comments): New function. (c-literal-limits): New function that finds the start and end pos of a comment or string surrounding point. (c-literal-limits-fast): A faster variant of `c-literal-limits' for newer Emacsen where the state returned from `parse-partial-sexp' contains the starting pos of the last literal. (c-parse-state): Use (c-point 'bod) instead of beginning-of-defun directly. (c-guess-basic-syntax): Fixed a few byte compiler warnings. (c-backward-to-start-of-do): Break infloop for invalid code, e.g. when someone types while (TRUE) { at the top of a buffer, we shouldn't hang when the { is typed! (c-backward-to-start-of-if): Ensure never move forward, not even if point < lim. (c-search-uplist-for-classkey): When searching up for a class key, instead of hardcoding the extended search for "extern", use the new variable c-extra-toplevel-key, which is language dependent. For C++, this variable includes the keyword "namespace" which will match C++ namespace introducing blocks. (c-guess-basic-syntax): Support for recognizing C++ namespace blocks, by elaborating on the mechanism used to find external language blocks. Searches which hardcoded "extern" now use c-extra-toplevel-key, a language dependent variable. Case clauses that were modified: CASE 5A.1, CASE 5A.4, CASE 5F, CASE 5I, CASE 14A. CASE 3: we can now determine whether we're at the beginning of a cpp macro definition, or inside the middle of one. Set syntax to 'cpp-macro in the former case, 'cpp-macro-cont in the latter. In both cases, the relpos is the beginning of the macro. (c-forward-syntactic-ws): Added code that skips forward over multi-line cpp macros. (c-beginning-of-macro): Moved, and made into a defsubst. This function can now actually find the beginning of a multi-line C preprocessor macro. (c-backward-syntactic-ws): Use c-beginning-of-macro to skip backwards over multi-line macro definitions. (c-in-literal, c-fast-in-literal): Use c-beginning-of-macro to find out whether we're in a multi-line macro definition. (c-fast-in-literal): Function which should be faster than c-in-literal. In XEmacs, this uses buffer-syntactic-context.
-rw-r--r--lisp/progmodes/cc-engine.el288
1 files changed, 209 insertions, 79 deletions
diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el
index 7d164f9e868..f4f37379a5b 100644
--- a/lisp/progmodes/cc-engine.el
+++ b/lisp/progmodes/cc-engine.el
@@ -1,6 +1,6 @@
1;;; cc-engine.el --- core syntax guessing engine for CC mode 1;;; cc-engine.el --- core syntax guessing engine for CC mode
2 2
3;; Copyright (C) 1985,87,92,93,94,95,96,97 Free Software Foundation, Inc. 3;; Copyright (C) 1985,87,92,93,94,95,96,97,98 Free Software Foundation, Inc.
4 4
5;; Authors: 1992-1997 Barry A. Warsaw 5;; Authors: 1992-1997 Barry A. Warsaw
6;; 1987 Dave Detlefs and Stewart Clamen 6;; 1987 Dave Detlefs and Stewart Clamen
@@ -231,36 +231,44 @@
231 231
232(defun c-forward-syntactic-ws (&optional lim) 232(defun c-forward-syntactic-ws (&optional lim)
233 ;; Forward skip of syntactic whitespace for Emacs 19. 233 ;; Forward skip of syntactic whitespace for Emacs 19.
234 (save-restriction 234 (let* ((here (point-max))
235 (let* ((lim (or lim (point-max))) 235 (hugenum (point-max)))
236 (here lim) 236 (while (/= here (point))
237 (hugenum (point-max))) 237 (setq here (point))
238 (narrow-to-region lim (point)) 238 (forward-comment hugenum)
239 (while (/= here (point)) 239 ;; skip preprocessor directives
240 (setq here (point)) 240 (when (and (eq (char-after) ?#)
241 (forward-comment hugenum)
242 ;; skip preprocessor directives
243 (if (and (eq (char-after) ?#)
244 (= (c-point 'boi) (point))) 241 (= (c-point 'boi) (point)))
245 (end-of-line) 242 (while (eq (char-before (c-point 'eol)) ?\\)
246 ))))) 243 (forward-line 1))
244 (end-of-line))
245 )
246 (if lim (goto-char (min (point) lim)))))
247
248(defsubst c-beginning-of-macro (&optional lim)
249 ;; Go to the beginning of a cpp macro definition. Leaves point at
250 ;; the beginning of the macro and returns t if in a cpp macro
251 ;; definition, otherwise returns nil and leaves point unchanged.
252 ;; `lim' is currently ignored, but the interface requires it.
253 (let ((here (point)))
254 (beginning-of-line)
255 (while (eq (char-before (1- (point))) ?\\)
256 (forward-line -1))
257 (back-to-indentation)
258 (if (eq (char-after) ?#)
259 t
260 (goto-char here)
261 nil)))
247 262
248(defun c-backward-syntactic-ws (&optional lim) 263(defun c-backward-syntactic-ws (&optional lim)
249 ;; Backward skip over syntactic whitespace for Emacs 19. 264 ;; Backward skip over syntactic whitespace for Emacs 19.
250 (save-restriction 265 (let* ((here (point-min))
251 (let* ((lim (or lim (c-point 'bod))) 266 (hugenum (- (point-max))))
252 (here lim) 267 (while (/= here (point))
253 (hugenum (- (point-max)))) 268 (setq here (point))
254 (if (< lim (point)) 269 (forward-comment hugenum)
255 (progn 270 (c-beginning-of-macro))
256 (narrow-to-region lim (point)) 271 (if lim (goto-char (max (point) lim)))))
257 (while (/= here (point))
258 (setq here (point))
259 (forward-comment hugenum)
260 (if (eq (c-in-literal lim) 'pound)
261 (beginning-of-line))
262 )))
263 )))
264 272
265 273
266;; Return `c' if in a C-style comment, `c++' if in a C++ style 274;; Return `c' if in a C-style comment, `c++' if in a C++ style
@@ -278,22 +286,118 @@
278 (aref c-in-literal-cache 1) 286 (aref c-in-literal-cache 1)
279 (let ((rtn (save-excursion 287 (let ((rtn (save-excursion
280 (let* ((lim (or lim (c-point 'bod))) 288 (let* ((lim (or lim (c-point 'bod)))
281 (here (point))
282 (state (parse-partial-sexp lim (point)))) 289 (state (parse-partial-sexp lim (point))))
283 (cond 290 (cond
284 ((nth 3 state) 'string) 291 ((nth 3 state) 'string)
285 ((nth 4 state) (if (nth 7 state) 'c++ 'c)) 292 ((nth 4 state) (if (nth 7 state) 'c++ 'c))
286 ((progn 293 ((c-beginning-of-macro lim) 'pound)
287 (goto-char here)
288 (beginning-of-line)
289 (looking-at "[ \t]*#"))
290 'pound)
291 (t nil)))))) 294 (t nil))))))
292 ;; cache this result if the cache is enabled 295 ;; cache this result if the cache is enabled
293 (and (boundp 'c-in-literal-cache) 296 (and (boundp 'c-in-literal-cache)
294 (setq c-in-literal-cache (vector (point) rtn))) 297 (setq c-in-literal-cache (vector (point) rtn)))
295 rtn))) 298 rtn)))
296 299
300;; XEmacs has a built-in function that should make this much quicker.
301;; I don't think we even need the cache, which makes our lives more
302;; complicated anyway. In this case, lim is ignored.
303(defun c-fast-in-literal (&optional lim)
304 (let ((context (buffer-syntactic-context)))
305 (cond
306 ((eq context 'string) 'string)
307 ((eq context 'comment) 'c++)
308 ((eq context 'block-comment) 'c)
309 ((save-excursion (c-beginning-of-macro lim)) 'pound))))
310
311(if (fboundp 'buffer-syntactic-context)
312 (defalias 'c-in-literal 'c-fast-in-literal))
313
314(defun c-literal-limits (&optional lim)
315 ;; Returns a cons of the beginning and end positions of the comment
316 ;; or string surrounding point (including both delimiters), or nil
317 ;; if point isn't in one. This is the Emacs 19 version.
318 (save-excursion
319 (let* ((lim (or lim (c-point 'bod)))
320 (state (parse-partial-sexp lim (point))))
321 (cond ((nth 3 state)
322 ;; String. Search backward for the start.
323 (while (nth 3 state)
324 (search-backward (make-string 1 (nth 3 state)))
325 (setq state (parse-partial-sexp lim (point))))
326 (cons (point) (or (c-safe (forward-sexp 1) (point))
327 (point-max))))
328 ((nth 7 state)
329 ;; C++ comment. Search from bol for the comment starter.
330 (beginning-of-line)
331 (setq state (parse-partial-sexp lim (point))
332 lim (point))
333 (while (not (nth 7 state))
334 (search-forward "//") ; Should never fail.
335 (setq state (parse-partial-sexp
336 lim (point) nil nil state)
337 lim (point)))
338 (backward-char 2)
339 (cons (point) (progn (forward-comment 1) (point))))
340 ((nth 4 state)
341 ;; C comment. Search backward for the comment starter.
342 (while (nth 4 state)
343 (search-backward "/*") ; Should never fail.
344 (setq state (parse-partial-sexp lim (point))))
345 (cons (point) (progn (forward-comment 1) (point))))
346 ((c-safe (nth 4 (parse-partial-sexp ; Can't use prev state due
347 lim (1+ (point))))) ; to bug in Emacs 19.34.
348 ;; We're standing in a comment starter.
349 (backward-char 2)
350 (cons (point) (progn (forward-comment 1) (point))))
351 ))))
352
353(defun c-literal-limits-fast (&optional lim)
354 ;; Returns a cons of the beginning and end positions of the comment
355 ;; or string surrounding point (including both delimiters), or nil
356 ;; if point isn't in one. This is for emacsen whose
357 ;; `parse-partial-sexp' returns the pos of the comment start.
358 (save-excursion
359 (let ((state (parse-partial-sexp lim (point))))
360 (cond ((nth 3 state) ; String.
361 (goto-char (nth 8 state))
362 (cons (point) (or (c-safe (forward-sexp 1) (point))
363 (point-max))))
364 ((nth 4 state) ; Comment.
365 (goto-char (nth 8 state))
366 (cons (point) (progn (forward-comment 1) (point))))
367 ((c-safe
368 (nth 4 (parse-partial-sexp ; Works?
369 (point) (1+ (point)) nil nil state)))
370 ;; We're in a comment starter.
371 (backward-char 2)
372 (cons (point) (progn (forward-comment 1) (point))))
373 ))))
374
375(defun c-collect-line-comments (range)
376 ;; If the argument is a cons of two buffer positions (such as
377 ;; returned by c-literal-limits), and that range contains a C++
378 ;; style line comment, then an extended range is returned that
379 ;; contains all adjacent line comments (i.e. all comments with no
380 ;; empty lines or non-whitespace characters between them).
381 ;; Otherwise the argument is returned.
382 (save-excursion
383 (condition-case nil
384 (if (and (consp range) (progn
385 (goto-char (car range))
386 (looking-at "//")))
387 (let ((beg (point)))
388 (while (and (not (bobp))
389 (forward-comment -1)
390 (looking-at "//"))
391 (setq beg (point)))
392 (cons beg (progn
393 (goto-char (cdr range))
394 (while (looking-at "[ \t]*//")
395 (forward-comment 1))
396 (point))))
397 range)
398 (error range))))
399
400
297 401
298;; utilities for moving and querying around syntactic elements 402;; utilities for moving and querying around syntactic elements
299(defvar c-parsing-error nil) 403(defvar c-parsing-error nil)
@@ -312,7 +416,7 @@
312 ;; in column zero) 416 ;; in column zero)
313 (let ((cnt 2)) 417 (let ((cnt 2))
314 (while (not (or at-bob (zerop cnt))) 418 (while (not (or at-bob (zerop cnt)))
315 (beginning-of-defun) 419 (goto-char (c-point 'bod))
316 (if (eq (char-after) ?\{) 420 (if (eq (char-after) ?\{)
317 (setq cnt (1- cnt))) 421 (setq cnt (1- cnt)))
318 (if (bobp) 422 (if (bobp)
@@ -472,11 +576,6 @@
472 (goto-char placeholder) 576 (goto-char placeholder)
473 (skip-chars-forward "^:" (c-point 'eol)))) 577 (skip-chars-forward "^:" (c-point 'eol))))
474 578
475(defun c-beginning-of-macro (&optional lim)
476 ;; Go to the beginning of the macro. Right now we don't support
477 ;; multi-line macros too well
478 (back-to-indentation))
479
480(defun c-in-method-def-p () 579(defun c-in-method-def-p ()
481 ;; Return nil if we aren't in a method definition, otherwise the 580 ;; Return nil if we aren't in a method definition, otherwise the
482 ;; position of the initial [+-]. 581 ;; position of the initial [+-].
@@ -545,6 +644,8 @@
545 (progn 644 (progn
546 (backward-sexp 1) 645 (backward-sexp 1)
547 (cond 646 (cond
647 ;; break infloop for illegal C code
648 ((bobp) (setq do-level 0))
548 ((memq (c-in-literal lim) '(c c++))) 649 ((memq (c-in-literal lim) '(c c++)))
549 ((looking-at "while\\b[^_]") 650 ((looking-at "while\\b[^_]")
550 (setq do-level (1+ do-level))) 651 (setq do-level (1+ do-level)))
@@ -569,7 +670,9 @@
569 (let ((if-level 1) 670 (let ((if-level 1)
570 (here (c-point 'bol)) 671 (here (c-point 'bol))
571 (case-fold-search nil) 672 (case-fold-search nil)
572 (lim (or lim (c-point 'bod))) 673 (lim (or (and (>= (point) lim)
674 lim)
675 (c-point 'bod)))
573 (at-if (looking-at "if\\b[^_]"))) 676 (at-if (looking-at "if\\b[^_]")))
574 (catch 'orphan-if 677 (catch 'orphan-if
575 (while (and (not (bobp)) 678 (while (and (not (bobp))
@@ -687,7 +790,7 @@
687 (save-excursion 790 (save-excursion
688 (save-restriction 791 (save-restriction
689 (goto-char search-start) 792 (goto-char search-start)
690 (let ((search-key (concat c-class-key "\\|extern[^_]")) 793 (let ((search-key (concat c-class-key "\\|" c-extra-toplevel-key))
691 foundp class match-end) 794 foundp class match-end)
692 (while (and (not foundp) 795 (while (and (not foundp)
693 (progn 796 (progn
@@ -862,17 +965,27 @@
862 (looking-at c-method-key))) 965 (looking-at c-method-key)))
863 literal containing-sexp char-before-ip char-after-ip lim 966 literal containing-sexp char-before-ip char-after-ip lim
864 syntax placeholder c-in-literal-cache inswitch-p 967 syntax placeholder c-in-literal-cache inswitch-p
865 injava-inher 968 tmpsymbol keyword injava-inher
866 ;; narrow out any enclosing class or extern "C" block 969 ;; narrow out any enclosing class or extern "C" block
867 (inclass-p (c-narrow-out-enclosing-class state indent-point)) 970 (inclass-p (c-narrow-out-enclosing-class state indent-point))
868 (inextern-p (and inclass-p 971 inenclosing-p)
869 (save-excursion 972 ;; check for meta top-level enclosing constructs, possible
870 (save-restriction 973 ;; extern language definitions, possibly (in C++) namespace
871 (widen) 974 ;; definitions.
872 (goto-char (aref inclass-p 0)) 975 (save-excursion
873 (looking-at "extern[^_]"))))) 976 (save-restriction
874 ) 977 (widen)
875 978 (if (and inclass-p
979 (progn
980 (goto-char (aref inclass-p 0))
981 (looking-at c-extra-toplevel-key)))
982 (let ((enclosing (match-string 1)))
983 (cond
984 ((string-equal enclosing "extern")
985 (setq inenclosing-p 'extern))
986 ((string-equal enclosing "namespace")
987 (setq inenclosing-p 'namespace))
988 )))))
876 ;; get the buffer position of the most nested opening brace, 989 ;; get the buffer position of the most nested opening brace,
877 ;; if there is one, and it hasn't been narrowed out 990 ;; if there is one, and it hasn't been narrowed out
878 (save-excursion 991 (save-excursion
@@ -927,10 +1040,14 @@
927 (while (and (zerop (forward-line -1)) 1040 (while (and (zerop (forward-line -1))
928 (looking-at "^[ \t]*$"))) 1041 (looking-at "^[ \t]*$")))
929 (c-add-syntax literal (c-point 'boi))) 1042 (c-add-syntax literal (c-point 'boi)))
930 ;; CASE 3: in a cpp preprocessor 1043 ;; CASE 3: in a cpp preprocessor macro
931 ((eq literal 'pound) 1044 ((eq literal 'pound)
932 (c-beginning-of-macro lim) 1045 (let ((boi (c-point 'boi))
933 (c-add-syntax 'cpp-macro (c-point 'boi))) 1046 (macrostart (progn (c-beginning-of-macro lim) (point))))
1047 (setq tmpsymbol (if (= boi macrostart)
1048 'cpp-macro
1049 'cpp-macro-cont))
1050 (c-add-syntax tmpsymbol macrostart)))
934 ;; CASE 4: in an objective-c method intro 1051 ;; CASE 4: in an objective-c method intro
935 (in-method-intro-p 1052 (in-method-intro-p
936 (c-add-syntax 'objc-method-intro (c-point 'boi))) 1053 (c-add-syntax 'objc-method-intro (c-point 'boi)))
@@ -941,19 +1058,25 @@
941 ;; inline-inclass method opening brace 1058 ;; inline-inclass method opening brace
942 ((eq char-after-ip ?{) 1059 ((eq char-after-ip ?{)
943 (cond 1060 (cond
944 ;; CASE 5A.1: extern declaration 1061 ;; CASE 5A.1: extern language or namespace construct
945 ((save-excursion 1062 ((save-excursion
946 (goto-char indent-point) 1063 (goto-char indent-point)
947 (skip-chars-forward " \t") 1064 (skip-chars-forward " \t")
948 (and (c-safe (progn (backward-sexp 2) t)) 1065 (and (c-safe (progn (backward-sexp 2) t))
949 (looking-at "extern[^_]") 1066 (looking-at c-extra-toplevel-key)
950 (progn 1067 (setq keyword (match-string 1)
951 (setq placeholder (point)) 1068 placeholder (point))
952 (forward-sexp 1) 1069 (or (and (string-equal keyword "namespace")
953 (c-forward-syntactic-ws) 1070 (setq tmpsymbol 'namespace-open))
954 (eq (char-after) ?\")))) 1071 (and (string-equal keyword "extern")
1072 (progn
1073 (forward-sexp 1)
1074 (c-forward-syntactic-ws)
1075 (eq (char-after) ?\"))
1076 (setq tmpsymbol 'extern-lang-open)))
1077 ))
955 (goto-char placeholder) 1078 (goto-char placeholder)
956 (c-add-syntax 'extern-lang-open (c-point 'boi))) 1079 (c-add-syntax tmpsymbol (c-point 'boi)))
957 ;; CASE 5A.2: we are looking at a class opening brace 1080 ;; CASE 5A.2: we are looking at a class opening brace
958 ((save-excursion 1081 ((save-excursion
959 (goto-char indent-point) 1082 (goto-char indent-point)
@@ -993,7 +1116,7 @@
993 ))) 1116 )))
994 (c-add-syntax 'brace-list-open placeholder)) 1117 (c-add-syntax 'brace-list-open placeholder))
995 ;; CASE 5A.4: inline defun open 1118 ;; CASE 5A.4: inline defun open
996 ((and inclass-p (not inextern-p)) 1119 ((and inclass-p (not inenclosing-p))
997 (c-add-syntax 'inline-open) 1120 (c-add-syntax 'inline-open)
998 (c-add-syntax 'inclass (aref inclass-p 0))) 1121 (c-add-syntax 'inclass (aref inclass-p 0)))
999 ;; CASE 5A.5: ordinary defun open 1122 ;; CASE 5A.5: ordinary defun open
@@ -1180,9 +1303,12 @@
1180 (c-add-syntax 'access-label (c-point 'bonl)) 1303 (c-add-syntax 'access-label (c-point 'bonl))
1181 (c-add-syntax 'inclass (aref inclass-p 0))) 1304 (c-add-syntax 'inclass (aref inclass-p 0)))
1182 ;; CASE 5F: extern-lang-close? 1305 ;; CASE 5F: extern-lang-close?
1183 ((and inextern-p 1306 ((and inenclosing-p
1184 (eq char-after-ip ?})) 1307 (eq char-after-ip ?}))
1185 (c-add-syntax 'extern-lang-close (aref inclass-p 0))) 1308 (setq tmpsymbol (if (eq inenclosing-p 'extern)
1309 'extern-lang-close
1310 'namespace-close))
1311 (c-add-syntax tmpsymbol (aref inclass-p 0)))
1186 ;; CASE 5G: we are looking at the brace which closes the 1312 ;; CASE 5G: we are looking at the brace which closes the
1187 ;; enclosing nested class decl 1313 ;; enclosing nested class decl
1188 ((and inclass-p 1314 ((and inclass-p
@@ -1261,10 +1387,14 @@
1261 (goto-char (aref inclass-p 1)) 1387 (goto-char (aref inclass-p 1))
1262 (or (= (point) (c-point 'boi)) 1388 (or (= (point) (c-point 'boi))
1263 (goto-char (aref inclass-p 0))) 1389 (goto-char (aref inclass-p 0)))
1264 (if inextern-p 1390 (cond
1265 (c-add-syntax 'inextern-lang) 1391 ((eq inenclosing-p 'extern)
1266 (c-add-syntax 'inclass (c-point 'boi))))) 1392 (c-add-syntax 'inextern-lang))
1267 )) 1393 ((eq inenclosing-p 'namespace)
1394 (c-add-syntax 'innamespace))
1395 (t (c-add-syntax 'inclass (c-point 'boi))))
1396 ))
1397 ))
1268 ;; CASE 5J: we are at an ObjC or Java method definition 1398 ;; CASE 5J: we are at an ObjC or Java method definition
1269 ;; continuation line. 1399 ;; continuation line.
1270 ((and c-method-key 1400 ((and c-method-key
@@ -1299,9 +1429,9 @@
1299 ;; CASE 6C: we are inside a conditional test clause. treat 1429 ;; CASE 6C: we are inside a conditional test clause. treat
1300 ;; these things as statements 1430 ;; these things as statements
1301 ((save-excursion 1431 ((save-excursion
1302 (goto-char containing-sexp) 1432 (goto-char containing-sexp)
1303 (and (c-safe (progn (forward-sexp -1) t)) 1433 (and (c-safe (progn (forward-sexp -1) t))
1304 (looking-at "\\<for\\>[^_]"))) 1434 (looking-at "\\<for\\>[^_]")))
1305 (goto-char (1+ containing-sexp)) 1435 (goto-char (1+ containing-sexp))
1306 (c-forward-syntactic-ws indent-point) 1436 (c-forward-syntactic-ws indent-point)
1307 (c-beginning-of-statement-1 containing-sexp) 1437 (c-beginning-of-statement-1 containing-sexp)
@@ -1381,7 +1511,7 @@
1381 (goto-char containing-sexp) 1511 (goto-char containing-sexp)
1382 (c-add-syntax 'brace-list-intro (c-point 'boi)) 1512 (c-add-syntax 'brace-list-intro (c-point 'boi))
1383 ) 1513 )
1384 ;;)) ; end CASE 8B 1514 ;;)) ; end CASE 8B
1385 ;; CASE 8C: this is just a later brace-list-entry 1515 ;; CASE 8C: this is just a later brace-list-entry
1386 (t (goto-char (1+ containing-sexp)) 1516 (t (goto-char (1+ containing-sexp))
1387 (c-forward-syntactic-ws indent-point) 1517 (c-forward-syntactic-ws indent-point)
@@ -1516,17 +1646,17 @@
1516 ((let ((inclass-p (progn 1646 ((let ((inclass-p (progn
1517 (goto-char containing-sexp) 1647 (goto-char containing-sexp)
1518 (c-search-uplist-for-classkey state)))) 1648 (c-search-uplist-for-classkey state))))
1519 ;; inextern-p in higher level let* 1649 ;; inenclosing-p in higher level let*
1520 (setq inextern-p (and inclass-p 1650 (setq inenclosing-p (and inclass-p
1521 (progn 1651 (progn
1522 (goto-char (aref inclass-p 0)) 1652 (goto-char (aref inclass-p 0))
1523 (looking-at "extern[^_]")))) 1653 (looking-at c-extra-toplevel-key))))
1524 (and inclass-p (not inextern-p))) 1654 (and inclass-p (not inenclosing-p)))
1525 (c-add-syntax 'inline-close relpos)) 1655 (c-add-syntax 'inline-close relpos))
1526 ;; CASE 14B: if there an enclosing brace that hasn't 1656 ;; CASE 14B: if there an enclosing brace that hasn't
1527 ;; been narrowed out by a class, then this is a 1657 ;; been narrowed out by a class, then this is a
1528 ;; block-close 1658 ;; block-close
1529 ((and (not inextern-p) 1659 ((and (not inenclosing-p)
1530 (c-most-enclosing-brace state)) 1660 (c-most-enclosing-brace state))
1531 (c-add-syntax 'block-close relpos)) 1661 (c-add-syntax 'block-close relpos))
1532 ;; CASE 14C: find out whether we're closing a top-level 1662 ;; CASE 14C: find out whether we're closing a top-level