Mercurial > emacs
annotate lisp/progmodes/cc-fonts.el @ 89708:b66b529d5f33
(x_set_mouse_face_gc): Call FACE_FOR_CHAR with POS and OBJECT args.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Thu, 15 Jan 2004 06:57:45 +0000 |
parents | 375f2633d815 |
children | 68c22ea6027c |
rev | line source |
---|---|
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1 ;;; cc-fonts.el --- font lock support for CC Mode |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
3 ;; Copyright (C) 2002, 03 Free Software Foundation, Inc. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
4 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
5 ;; Authors: 2003- Alan Mackenzie |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
6 ;; 2002- Martin Stjernholm |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
7 ;; Maintainer: bug-cc-mode@gnu.org |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
8 ;; Created: 07-Jan-2002 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
9 ;; Version: See cc-mode.el |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
10 ;; Keywords: c languages oop |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
11 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
12 ;; This file is part of GNU Emacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
13 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
14 ;; GNU Emacs is free software; you can redistribute it and/or modify |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
15 ;; it under the terms of the GNU General Public License as published by |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
16 ;; the Free Software Foundation; either version 2, or (at your option) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
17 ;; any later version. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
18 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
19 ;; GNU Emacs is distributed in the hope that it will be useful, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
22 ;; GNU General Public License for more details. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
23 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
24 ;; You should have received a copy of the GNU General Public License |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
25 ;; along with this program; see the file COPYING. If not, write to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
26 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
27 ;; Boston, MA 02111-1307, USA. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
28 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
29 ;;; Commentary: |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
30 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
31 ;; Some comments on the use of faces: |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
32 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
33 ;; o `c-label-face-name' is either `font-lock-constant-face' (in Emacs |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
34 ;; 20 and later), or `font-lock-reference-face'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
35 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
36 ;; o `c-constant-face-name', `c-reference-face-name' and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
37 ;; `c-doc-markup-face-name' are essentially set up like |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
38 ;; `c-label-face-name'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
39 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
40 ;; o `c-preprocessor-face-name' is `font-lock-preprocessor-face' in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
41 ;; XEmacs and - in lack of a closer equivalent - |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
42 ;; `font-lock-builtin-face' or `font-lock-reference-face' in Emacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
43 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
44 ;; o `c-doc-face-name' is `font-lock-doc-string-face' in XEmacs, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
45 ;; `font-lock-doc-face' in Emacs 21 and later, or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
46 ;; `font-lock-comment-face' in older Emacs (that since source |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
47 ;; documentation are actually comments in these languages, as opposed |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
48 ;; to elisp). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
49 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
50 ;; o `c-invalid-face-name' is `font-lock-warning-face' in Emacs. In |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
51 ;; older XEmacs there's no corresponding standard face, so there |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
52 ;; it's mapped to a special `c-invalid-face'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
53 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
54 ;; TBD: We should probably provide real faces for the above uses and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
55 ;; instead initialize them from the standard faces. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
56 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
57 ;;; Code: |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
58 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
59 ;; The faces that already have been put onto the text is tested in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
60 ;; various places to direct further fontifications. For this to work, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
61 ;; the following assumptions regarding the faces must hold (apart from |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
62 ;; the dependencies on the font locking order): |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
63 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
64 ;; o `font-lock-comment-face' and the face in `c-doc-face-name' is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
65 ;; not used in anything but comments. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
66 ;; o If any face (e.g. `c-doc-markup-face-name') but those above is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
67 ;; used in comments, it doesn't replace them. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
68 ;; o `font-lock-string-face' is not used in anything but string |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
69 ;; literals (single or double quoted). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
70 ;; o `font-lock-keyword-face' and the face in `c-label-face-name' are |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
71 ;; never overlaid with other faces. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
72 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
73 (eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
74 (let ((load-path |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
75 (if (and (boundp 'byte-compile-dest-file) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
76 (stringp byte-compile-dest-file)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
77 (cons (file-name-directory byte-compile-dest-file) load-path) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
78 load-path))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
79 (load "cc-bytecomp" nil t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
80 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
81 (cc-require 'cc-defs) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
82 (cc-require-when-compile 'cc-langs) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
83 (cc-require 'cc-vars) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
84 (cc-require 'cc-engine) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
85 (cc-require-when-compile 'cc-awk) ; Change from cc-require, 2003/6/18 to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
86 ;; prevent cc-awk being loaded when it's not needed. There is now a (require |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
87 ;; 'cc-awk) in (defun awk-mode ..). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
88 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
89 ;; Avoid repeated loading through the eval-after-load directive in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
90 ;; cc-mode.el. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
91 (provide 'cc-fonts) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
92 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
93 (cc-external-require 'font-lock) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
94 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
95 (cc-bytecomp-defvar parse-sexp-lookup-properties) ; Emacs only. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
96 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
97 ;; Need to declare these local symbols during compilation since |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
98 ;; they're referenced from lambdas in `byte-compile' calls that are |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
99 ;; executed at compile time. They don't need to have the proper |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
100 ;; definitions, though, since the generated functions aren't called |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
101 ;; during compilation. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
102 (cc-bytecomp-defvar c-preprocessor-face-name) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
103 (cc-bytecomp-defvar c-reference-face-name) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
104 (cc-bytecomp-defun c-fontify-recorded-types-and-refs) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
105 (cc-bytecomp-defun c-font-lock-declarators) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
106 (cc-bytecomp-defun c-font-lock-objc-iip-decl) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
107 (cc-bytecomp-defun c-font-lock-objc-method) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
108 (cc-bytecomp-defun c-font-lock-invalid-string) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
109 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
110 ;; Emacs 19 doesn't have `defface'. This "replacement" leaves a lot |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
111 ;; to be wished for but at least it avoids any errors. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
112 (cc-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
113 (or (fboundp 'defface) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
114 (cc-bytecomp-defmacro defface (face spec doc &rest args) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
115 `(make-face ',face)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
116 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
117 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
118 ;; Note that font-lock in XEmacs doesn't expand face names as |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
119 ;; variables, so we have to use the (eval . FORM) in the font lock |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
120 ;; matchers wherever we use these alias variables. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
121 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
122 (defconst c-preprocessor-face-name |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
123 (cond ((c-face-name-p 'font-lock-preprocessor-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
124 ;; XEmacs has a font-lock-preprocessor-face. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
125 'font-lock-preprocessor-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
126 ((c-face-name-p 'font-lock-builtin-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
127 ;; In Emacs 20 and later font-lock-builtin-face has |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
128 ;; traditionally been used for preprocessor directives. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
129 'font-lock-builtin-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
130 (t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
131 'font-lock-reference-face))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
132 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
133 (cc-bytecomp-defvar font-lock-constant-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
134 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
135 (defconst c-label-face-name |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
136 (cond ((c-face-name-p 'font-lock-label-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
137 ;; If it happens to occur in the future. (Well, the more |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
138 ;; pragmatic reason is to get unique faces for the test |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
139 ;; suite.) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
140 'font-lock-label-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
141 ((and (c-face-name-p 'font-lock-constant-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
142 (eq font-lock-constant-face 'font-lock-constant-face)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
143 ;; Test both if font-lock-constant-face exists and that it's |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
144 ;; not an alias for something else. This is important since |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
145 ;; we compare already set faces in various places. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
146 'font-lock-constant-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
147 (t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
148 'font-lock-reference-face))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
149 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
150 (defconst c-constant-face-name |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
151 (if (and (c-face-name-p 'font-lock-constant-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
152 (eq font-lock-constant-face 'font-lock-constant-face)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
153 ;; This doesn't exist in XEmacs <= 20 and some earlier versions |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
154 ;; of XEmacs 21. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
155 'font-lock-constant-face |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
156 c-label-face-name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
157 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
158 (defconst c-reference-face-name |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
159 (if (and (c-face-name-p 'font-lock-reference-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
160 (eq font-lock-reference-face 'font-lock-reference-face)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
161 ;; This is considered obsolete in Emacs 20 and later, but it |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
162 ;; still maps well to this use. (Another reason to do this is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
163 ;; to get unique faces for the test suite.) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
164 'font-lock-reference-face |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
165 c-label-face-name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
166 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
167 ;; This should not mapped to a face that also is used to fontify things |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
168 ;; that aren't comments or string literals. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
169 (defconst c-doc-face-name |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
170 (cond ((c-face-name-p 'font-lock-doc-string-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
171 ;; XEmacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
172 'font-lock-doc-string-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
173 ((c-face-name-p 'font-lock-doc-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
174 ;; Emacs 21 and later. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
175 'font-lock-doc-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
176 (t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
177 'font-lock-comment-face))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
178 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
179 (defconst c-doc-markup-face-name |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
180 (if (c-face-name-p 'font-lock-doc-markup-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
181 ;; If it happens to occur in the future. (Well, the more |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
182 ;; pragmatic reason is to get unique faces for the test |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
183 ;; suite.) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
184 'font-lock-doc-markup-face |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
185 c-label-face-name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
186 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
187 (defconst c-invalid-face-name |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
188 (if (c-face-name-p 'font-lock-warning-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
189 ;; Emacs >= 20 and XEmacs >= 21 has a font-lock-warning-face. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
190 'font-lock-warning-face |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
191 ;; Otherwise we provide a face. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
192 'c-invalid-face)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
193 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
194 (unless (c-face-name-p c-invalid-face-name) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
195 (defconst c-invalid-face 'c-invalid-face) ; Necessary in Emacs 19. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
196 (defface c-invalid-face |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
197 '((((class color) (background light)) (:foreground "red")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
198 (((class color)) (:foreground "hotpink")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
199 (t (:inverse-video t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
200 "Face used to highlight invalid syntax." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
201 :group 'c-fonts)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
202 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
203 ;; To make hard spaces visible an inverted version of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
204 ;; `c-invalid-face-name' is used. Since font-lock in Emacs expands |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
205 ;; all face names in `font-lock-keywords' as variables we need to have |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
206 ;; a variable for it that resolves to its own name. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
207 (defconst c-nonbreakable-space-face 'c-nonbreakable-space-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
208 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
209 (cc-bytecomp-defun face-inverse-video-p) ; Only in Emacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
210 (cc-bytecomp-defun face-property-instance) ; Only in XEmacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
211 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
212 (defun c-make-inverse-face (oldface newface) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
213 ;; Emacs and XEmacs have completely different face manipulation |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
214 ;; routines. :P |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
215 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
216 ;; This function does not do any hidden buffer changes |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
217 (copy-face oldface newface) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
218 (cond ((fboundp 'face-inverse-video-p) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
219 ;; Emacs 20 and later. This only looks at the inverse flag |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
220 ;; in the current frame. Other display configurations might |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
221 ;; be different, but it can only show if the same Emacs has |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
222 ;; frames on e.g. a color and a monochrome display |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
223 ;; simultaneously. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
224 (unless (face-inverse-video-p oldface) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
225 (invert-face newface))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
226 ((fboundp 'face-property-instance) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
227 ;; XEmacs. Same pitfall here. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
228 (unless (face-property-instance oldface 'reverse) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
229 (invert-face newface))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
230 (t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
231 ;; Emacs 19 has no inverse flag at all. Just inverse the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
232 ;; face and hope it wasn't inversed already. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
233 (invert-face newface)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
234 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
235 (eval-and-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
236 ;; We need the following functions during compilation since they're |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
237 ;; called when the `c-lang-defconst' initializers are evaluated. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
238 ;; Define them at runtime too for the sake of derived modes. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
239 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
240 (defmacro c-put-font-lock-face (from to face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
241 ;; Put a face on a region (overriding any existing face) in the way |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
242 ;; font-lock would do it. In XEmacs that means putting an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
243 ;; additional font-lock property, or else the font-lock package |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
244 ;; won't recognize it as fontified and might override it |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
245 ;; incorrectly. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
246 (if (fboundp 'font-lock-set-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
247 ;; Note: This function has no docstring in XEmacs so it might be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
248 ;; considered internal. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
249 `(font-lock-set-face ,from ,to ,face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
250 `(put-text-property ,from ,to 'face ,face))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
251 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
252 (defmacro c-remove-font-lock-face (from to) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
253 ;; This is the inverse of `c-put-font-lock-face'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
254 (if (fboundp 'font-lock-remove-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
255 `(font-lock-remove-face ,from ,to) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
256 `(remove-text-properties ,from ,to '(face nil)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
257 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
258 (defmacro c-put-font-lock-string-face (from to) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
259 ;; Put `font-lock-string-face' on a string. The surrounding |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
260 ;; quotes are included in Emacs but not in XEmacs. The passed |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
261 ;; region should include them. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
262 (if (featurep 'xemacs) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
263 `(c-put-font-lock-face (1+ ,from) (1- ,to) 'font-lock-string-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
264 `(c-put-font-lock-face ,from ,to 'font-lock-string-face))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
265 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
266 (defmacro c-fontify-types-and-refs (varlist &rest body) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
267 ;; Like `let', but additionally activates `c-record-type-identifiers' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
268 ;; and `c-record-ref-identifiers', and fontifies the recorded ranges |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
269 ;; accordingly on exit. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
270 `(let ((c-record-type-identifiers t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
271 c-record-ref-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
272 ,@varlist) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
273 (prog1 (progn ,@body) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
274 (c-fontify-recorded-types-and-refs)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
275 (put 'c-fontify-types-and-refs 'lisp-indent-function 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
276 (eval-after-load "edebug" '(def-edebug-spec c-fontify-types-and-refs let*)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
277 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
278 (defun c-skip-comments-and-strings (limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
279 ;; If the point is within a region fontified as a comment or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
280 ;; string literal skip to the end of it or to LIMIT, whichever |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
281 ;; comes first, and return t. Otherwise return nil. The match |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
282 ;; data is not clobbered. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
283 (when (c-got-face-at (point) c-literal-faces) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
284 (while (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
285 (goto-char (next-single-property-change |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
286 (point) 'face nil limit)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
287 (and (< (point) limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
288 (c-got-face-at (point) c-literal-faces)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
289 t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
290 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
291 (defun c-make-font-lock-search-function (regexp &rest highlights) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
292 ;; This function makes a byte compiled function that works much like |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
293 ;; a matcher element in `font-lock-keywords'. It cuts out a little |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
294 ;; bit of the overhead compared to a real matcher. The main reason |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
295 ;; is however to pass the real search limit to the anchored |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
296 ;; matcher(s), since most (if not all) font-lock implementations |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
297 ;; arbitrarily limits anchored matchers to the same line, and also |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
298 ;; to insulate against various other irritating differences between |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
299 ;; the different (X)Emacs font-lock packages. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
300 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
301 ;; REGEXP is the matcher, which must be a regexp. Only matches |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
302 ;; where the beginning is outside any comment or string literal are |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
303 ;; significant. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
304 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
305 ;; HIGHLIGHTS is a list of highlight specs, just like in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
306 ;; `font-lock-keywords', with these limitations: The face is always |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
307 ;; overridden (no big disadvantage, since hits in comments etc are |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
308 ;; filtered anyway), there is no "laxmatch", and an anchored matcher |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
309 ;; is always a form which must do all the fontification directly. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
310 ;; `limit' is a variable bound to the real limit in the context of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
311 ;; the anchored matcher forms. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
312 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
313 ;; This function does not do any hidden buffer changes, but the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
314 ;; generated functions will. They are however used in places |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
315 ;; covered by the font-lock context. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
316 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
317 ;; Note: Replace `byte-compile' with `eval' to debug the generated |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
318 ;; lambda easier. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
319 (byte-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
320 `(lambda (limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
321 (let (-match-end-pos- |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
322 ;; The font-lock package in Emacs is known to clobber |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
323 ;; `parse-sexp-lookup-properties' (when it exists). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
324 (parse-sexp-lookup-properties |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
325 (cc-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
326 (boundp 'parse-sexp-lookup-properties)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
327 (while (re-search-forward ,regexp limit t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
328 (setq -match-end-pos- (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
329 (unless (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
330 (goto-char (match-beginning 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
331 (c-skip-comments-and-strings limit)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
332 (goto-char -match-end-pos-) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
333 ,@(mapcar |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
334 (lambda (highlight) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
335 (if (integerp (car highlight)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
336 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
337 (unless (nth 2 highlight) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
338 (error |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
339 "The override flag must currently be set in %s" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
340 highlight)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
341 (when (nth 3 highlight) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
342 (error |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
343 "The laxmatch flag may currently not be set in %s" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
344 highlight)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
345 `(save-match-data |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
346 (c-put-font-lock-face |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
347 (match-beginning ,(car highlight)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
348 (match-end ,(car highlight)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
349 ,(elt highlight 1)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
350 (when (nth 3 highlight) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
351 (error "Match highlights currently not supported in %s" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
352 highlight)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
353 `(progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
354 ,(nth 1 highlight) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
355 (save-match-data ,(car highlight)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
356 ,(nth 2 highlight)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
357 highlights)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
358 nil)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
359 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
360 (defun c-fontify-recorded-types-and-refs () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
361 ;; Converts the ranges recorded on `c-record-type-identifiers' and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
362 ;; `c-record-ref-identifiers' to fontification. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
363 (let (elem) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
364 (while (consp c-record-type-identifiers) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
365 (setq elem (car c-record-type-identifiers) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
366 c-record-type-identifiers (cdr c-record-type-identifiers)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
367 (c-put-font-lock-face (car elem) (cdr elem) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
368 'font-lock-type-face)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
369 (while c-record-ref-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
370 (setq elem (car c-record-ref-identifiers) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
371 c-record-ref-identifiers (cdr c-record-ref-identifiers)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
372 ;; Note that the reference face is a variable that is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
373 ;; dereferenced, since it's an alias in Emacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
374 (c-put-font-lock-face (car elem) (cdr elem) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
375 c-reference-face-name)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
376 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
377 (c-lang-defconst c-cpp-matchers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
378 "Font lock matchers for preprocessor directives and purely lexical |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
379 stuff. Used on level 1 and higher." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
380 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
381 ;; Note: `c-font-lock-declarations' assumes that no matcher here |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
382 ;; sets `font-lock-type-face' in languages where |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
383 ;; `c-recognize-<>-arglists' is set. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
384 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
385 t `(,@(when (c-lang-const c-opt-cpp-prefix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
386 (let* ((noncontinued-line-end "\\(\\=\\|\\(\\=\\|[^\\]\\)[\n\r]\\)") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
387 (ncle-depth (c-regexp-opt-depth noncontinued-line-end)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
388 (sws-depth (c-lang-const c-syntactic-ws-depth))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
389 `(;; The stuff after #error and #warning is a message, so |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
390 ;; fontify it as a string. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
391 (,(concat noncontinued-line-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
392 (c-lang-const c-opt-cpp-prefix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
393 "\\(error\\|warning\\)\\>\\s *\\(.*\\)$") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
394 ,(+ ncle-depth 2) font-lock-string-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
395 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
396 ;; Fontify filenames in #include <...> as strings. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
397 (,(concat noncontinued-line-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
398 (c-lang-const c-opt-cpp-prefix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
399 "\\(import\\|include\\)\\>" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
400 (c-lang-const c-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
401 "\\(<[^>\n\r]*>?\\)") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
402 (,(+ ncle-depth sws-depth 2) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
403 font-lock-string-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
404 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
405 ;; Use an anchored matcher to put paren syntax on the brackets. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
406 (,(byte-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
407 `(lambda (limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
408 (let ((beg-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
409 (match-beginning ,(+ ncle-depth sws-depth 2))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
410 (end-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
411 (1- (match-end ,(+ ncle-depth sws-depth 2))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
412 (if (eq (char-after end-pos) ?>) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
413 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
414 (c-mark-<-as-paren beg-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
415 (c-mark->-as-paren end-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
416 (c-clear-char-property beg-pos 'syntax-table))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
417 nil)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
418 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
419 ;; #define. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
420 (,(c-make-font-lock-search-function |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
421 (concat |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
422 noncontinued-line-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
423 (c-lang-const c-opt-cpp-prefix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
424 "define\\>" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
425 (c-lang-const c-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
426 "\\(" (c-lang-const c-symbol-key) "\\)" ; 1 + ncle + sws |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
427 (concat "\\(" ; 2 + ncle + sws + c-sym-key |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
428 ;; Macro with arguments - a "function". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
429 "\\(\(\\)" ; 3 + ncle + sws + c-sym-key |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
430 "\\|" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
431 ;; Macro without arguments - a "variable". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
432 "\\([^\(]\\|$\\)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
433 "\\)")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
434 `((if (match-beginning ,(+ 3 ncle-depth sws-depth |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
435 (c-lang-const c-symbol-key-depth))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
436 ;; "Function". Fontify the name and the arguments. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
437 (save-restriction |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
438 (c-put-font-lock-face |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
439 (match-beginning ,(+ 1 ncle-depth sws-depth)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
440 (match-end ,(+ 1 ncle-depth sws-depth)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
441 'font-lock-function-name-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
442 (goto-char (match-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
443 ,(+ 3 ncle-depth sws-depth |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
444 (c-lang-const c-symbol-key-depth)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
445 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
446 (narrow-to-region (point-min) limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
447 (while (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
448 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
449 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
450 (looking-at c-symbol-key)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
451 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
452 (c-put-font-lock-face |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
453 (match-beginning 0) (match-end 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
454 'font-lock-variable-name-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
455 (goto-char (match-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
456 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
457 (eq (char-after) ?,))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
458 (forward-char))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
459 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
460 ;; "Variable". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
461 (c-put-font-lock-face |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
462 (match-beginning ,(+ 1 ncle-depth sws-depth)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
463 (match-end ,(+ 1 ncle-depth sws-depth)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
464 'font-lock-variable-name-face))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
465 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
466 ;; Fontify cpp function names in preprocessor |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
467 ;; expressions in #if and #elif. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
468 ,(when (c-lang-const c-cpp-defined-fns) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
469 `(,(c-make-font-lock-search-function |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
470 (concat noncontinued-line-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
471 (c-lang-const c-opt-cpp-prefix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
472 "\\(if\\|elif\\)\\>" ; 1 + ncle-depth |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
473 ;; Match the whole logical line to look |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
474 ;; for the functions in. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
475 "\\(\\\\\\(.\\|[\n\r]\\)\\|[^\n\r]\\)*") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
476 `((let ((limit (match-end 0))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
477 (while (re-search-forward |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
478 ,(concat "\\<\\(" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
479 (c-regexp-opt |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
480 (c-lang-const c-cpp-defined-fns) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
481 nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
482 "\\)\\>" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
483 "\\s *\(?") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
484 limit 'move) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
485 (c-put-font-lock-face (match-beginning 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
486 (match-end 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
487 c-preprocessor-face-name))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
488 (goto-char (match-end ,(1+ ncle-depth))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
489 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
490 ;; Fontify the directive names. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
491 (,(c-make-font-lock-search-function |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
492 (concat noncontinued-line-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
493 "\\(" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
494 (c-lang-const c-opt-cpp-prefix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
495 "[" (c-lang-const c-symbol-chars) "]+" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
496 "\\)") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
497 `(,(1+ ncle-depth) c-preprocessor-face-name t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
498 ))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
499 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
500 ,@(when (c-major-mode-is 'pike-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
501 `((eval . (list "\\`#![^\n\r]*" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
502 0 c-preprocessor-face-name)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
503 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
504 ;; Make hard spaces visible through an inverted `c-invalid-face-name'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
505 (eval . (list |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
506 "\240" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
507 0 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
508 (unless (c-face-name-p 'c-nonbreakable-space-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
509 (c-make-inverse-face c-invalid-face-name |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
510 'c-nonbreakable-space-face)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
511 'c-nonbreakable-space-face))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
512 )) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
513 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
514 (defun c-font-lock-invalid-string () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
515 ;; Assuming the point is after the opening character of a string, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
516 ;; fontify that char with `c-invalid-face-name' if the string |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
517 ;; decidedly isn't terminated properly. Assumes the string already |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
518 ;; is syntactically fontified. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
519 (let ((end (1+ (c-point 'eol)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
520 (and (eq (get-text-property (point) 'face) 'font-lock-string-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
521 (= (next-single-property-change (point) 'face nil end) end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
522 ;; We're at eol inside a string. The first check above is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
523 ;; necessary in XEmacs since it doesn't fontify the string |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
524 ;; delimiters themselves. Thus an empty string won't have |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
525 ;; the string face anywhere. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
526 (if (c-major-mode-is '(c-mode c++-mode objc-mode pike-mode)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
527 ;; There's no \ before the newline. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
528 (not (eq (char-before (1- end)) ?\\)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
529 ;; Quoted newlines aren't supported. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
530 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
531 (if (c-major-mode-is 'pike-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
532 ;; There's no # before the string, so newlines |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
533 ;; aren't allowed. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
534 (not (eq (char-before (1- (point))) ?#)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
535 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
536 (c-put-font-lock-face (1- (point)) (point) c-invalid-face-name)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
537 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
538 (c-lang-defconst c-basic-matchers-before |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
539 "Font lock matchers for basic keywords, labels, references and various |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
540 other easily recognizable things that should be fontified before generic |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
541 casts and declarations are fontified. Used on level 2 and higher." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
542 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
543 ;; Note: `c-font-lock-declarations' assumes that no matcher here |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
544 ;; sets `font-lock-type-face' in languages where |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
545 ;; `c-recognize-<>-arglists' is set. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
546 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
547 t `(;; Put a warning face on the opener of unclosed strings that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
548 ;; can't span lines. Later font |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
549 ;; lock packages have a `font-lock-syntactic-face-function' for |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
550 ;; this, but it doesn't give the control we want since any |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
551 ;; fontification done inside the function will be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
552 ;; unconditionally overridden. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
553 ,(c-make-font-lock-search-function |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
554 ;; Match a char before the string starter to make |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
555 ;; `c-skip-comments-and-strings' work correctly. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
556 (concat ".\\(" c-string-limit-regexp "\\)") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
557 '((c-font-lock-invalid-string))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
558 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
559 ;; Fontify keyword constants. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
560 ,@(when (c-lang-const c-constant-kwds) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
561 (let ((re (c-make-keywords-re nil (c-lang-const c-constant-kwds)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
562 (if (c-major-mode-is 'pike-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
563 ;; No symbol is a keyword after "->" in Pike. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
564 `((eval . (list ,(concat "\\(\\=\\|\\(\\=\\|[^-]\\)[^>]\\)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
565 "\\<\\(" re "\\)\\>") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
566 3 c-constant-face-name))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
567 `((eval . (list ,(concat "\\<\\(" re "\\)\\>") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
568 1 c-constant-face-name)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
569 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
570 ;; Fontify all keywords except the primitive types. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
571 ,(if (c-major-mode-is 'pike-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
572 ;; No symbol is a keyword after "->" in Pike. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
573 `(,(concat "\\(\\=\\|\\(\\=\\|[^-]\\)[^>]\\)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
574 "\\<" (c-lang-const c-regular-keywords-regexp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
575 3 font-lock-keyword-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
576 `(,(concat "\\<" (c-lang-const c-regular-keywords-regexp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
577 1 font-lock-keyword-face)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
578 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
579 ;; Fontify leading identifiers in fully qualified names like |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
580 ;; "foo::bar" in languages that supports such things. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
581 ,@(when (c-lang-const c-opt-identifier-concat-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
582 `((,(byte-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
583 ;; Must use a function here since we match longer |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
584 ;; than we want to move before doing a new search. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
585 ;; This is not necessary for XEmacs >= 20 since it |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
586 ;; restarts the search from the end of the first |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
587 ;; highlighted submatch (something that causes |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
588 ;; problems in other places). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
589 `(lambda (limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
590 (while (re-search-forward |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
591 ,(concat "\\(\\<" ; 1 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
592 "\\(" (c-lang-const c-symbol-key) "\\)" ; 2 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
593 "[ \t\n\r\f\v]*" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
594 (c-lang-const c-opt-identifier-concat-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
595 "[ \t\n\r\f\v]*" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
596 "\\)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
597 "\\(" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
598 (c-lang-const c-opt-after-id-concat-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
599 "\\)") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
600 limit t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
601 (unless (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
602 (goto-char (match-beginning 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
603 (c-skip-comments-and-strings limit)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
604 (or (get-text-property (match-beginning 2) 'face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
605 (c-put-font-lock-face (match-beginning 2) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
606 (match-end 2) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
607 c-reference-face-name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
608 (goto-char (match-end 1))))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
609 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
610 ;; Fontify the special declarations in Objective-C. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
611 ,@(when (c-major-mode-is 'objc-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
612 `(;; Fontify class names in the beginning of message expressions. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
613 ,(c-make-font-lock-search-function |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
614 "\\[" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
615 '((c-fontify-types-and-refs () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
616 (c-forward-syntactic-ws limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
617 (let ((start (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
618 ;; In this case we accept both primitive and known types. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
619 (when (eq (c-forward-type) 'known) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
620 (goto-char start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
621 (let ((c-promote-possible-types t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
622 (c-forward-type)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
623 (if (> (point) limit) (goto-char limit))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
624 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
625 ;; The @interface/@implementation/@protocol directives. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
626 (,(concat "\\<" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
627 (c-regexp-opt |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
628 '("@interface" "@implementation" "@protocol") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
629 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
630 "\\>") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
631 (,(byte-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
632 (lambda (limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
633 (let (;; The font-lock package in Emacs is known to clobber |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
634 ;; `parse-sexp-lookup-properties' (when it exists). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
635 (parse-sexp-lookup-properties |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
636 (cc-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
637 (boundp 'parse-sexp-lookup-properties)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
638 (save-restriction |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
639 (narrow-to-region (point-min) limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
640 (c-font-lock-objc-iip-decl))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
641 nil)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
642 )) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
643 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
644 (defun c-font-lock-complex-decl-prepare (limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
645 ;; Called before any of the matchers in `c-complex-decl-matchers'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
646 ;; Nil is always returned. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
647 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
648 ;;(message "c-font-lock-complex-decl-prepare %s %s" (point) limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
649 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
650 ;; Clear the list of found types if we start from the start of the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
651 ;; buffer, to make it easier to get rid of misspelled types and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
652 ;; variables that has gotten recognized as types in malformed code. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
653 (when (bobp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
654 (c-clear-found-types)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
655 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
656 ;; Clear the c-type char properties in the region to recalculate |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
657 ;; them properly. This is necessary e.g. to handle constructs that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
658 ;; might been required as declarations temporarily during editing. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
659 ;; The interesting properties are anyway those put on the closest |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
660 ;; token before the region. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
661 (c-clear-char-properties (point) limit 'c-type) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
662 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
663 ;; Update `c-state-cache' to the beginning of the region. This will |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
664 ;; make `c-beginning-of-syntax' go faster when it's used later on, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
665 ;; and it's near the point most of the time. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
666 (c-parse-state) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
667 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
668 ;; Check if the fontified region starts inside a declarator list so |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
669 ;; that `c-font-lock-declarators' should be called at the start. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
670 (let ((prop (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
671 (c-backward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
672 (unless (bobp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
673 (c-get-char-property (1- (point)) 'c-type))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
674 (when (memq prop '(c-decl-id-start c-decl-type-start)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
675 (c-forward-syntactic-ws limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
676 (c-font-lock-declarators limit t (eq prop 'c-decl-type-start)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
677 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
678 nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
679 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
680 (defun c-font-lock-<>-arglists (limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
681 ;; Fontify types and references in names containing angle bracket |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
682 ;; arglists from the point to LIMIT. This will also fontify cases |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
683 ;; like normal function calls on the form "foo (a < b, c > d)", but |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
684 ;; `c-font-lock-declarations' will undo that later. Nil is always |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
685 ;; returned. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
686 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
687 (let (;; The font-lock package in Emacs is known to clobber |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
688 ;; `parse-sexp-lookup-properties' (when it exists). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
689 (parse-sexp-lookup-properties |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
690 (cc-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
691 (boundp 'parse-sexp-lookup-properties))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
692 id-start id-end pos kwd-sym) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
693 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
694 (while (and (< (point) limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
695 (re-search-forward c-opt-<>-arglist-start limit t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
696 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
697 (setq id-start (match-beginning 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
698 id-end (match-end 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
699 pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
700 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
701 (goto-char id-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
702 (unless (c-skip-comments-and-strings limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
703 (setq kwd-sym nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
704 (if (or (not (eq (get-text-property id-start 'face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
705 'font-lock-keyword-face)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
706 (when (looking-at c-opt-<>-sexp-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
707 (setq kwd-sym (c-keyword-sym (match-string 1))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
708 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
709 (goto-char (1- pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
710 ;; Check for comment/string both at the identifier and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
711 ;; at the "<". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
712 (unless (c-skip-comments-and-strings limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
713 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
714 (when (c-forward-<>-arglist (c-keyword-member kwd-sym |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
715 'c-<>-type-kwds) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
716 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
717 (when (and c-opt-identifier-concat-key |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
718 (not (get-text-property id-start 'face))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
719 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
720 (if (looking-at c-opt-identifier-concat-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
721 (c-put-font-lock-face id-start id-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
722 c-reference-face-name) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
723 (c-put-font-lock-face id-start id-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
724 'font-lock-type-face)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
725 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
726 (goto-char pos))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
727 (goto-char pos))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
728 nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
729 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
730 (defun c-font-lock-declarators (limit list types) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
731 ;; Assuming the point is at the start of a declarator in a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
732 ;; declaration, fontify it. If LIST is non-nil, fontify also all |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
733 ;; following declarators in a comma separated list (e.g. "foo" and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
734 ;; "bar" in "int foo = 17, bar;"). Stop at LIMIT. If TYPES is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
735 ;; non-nil, fontify all identifiers as types. Nil is always |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
736 ;; returned. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
737 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
738 ;;(message "c-font-lock-declarators from %s to %s" (point) limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
739 (c-fontify-types-and-refs |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
740 ((pos (point)) next-pos id-start id-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
741 paren-depth |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
742 id-face got-init |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
743 c-last-identifier-range |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
744 (separator-prop (if types 'c-decl-type-start 'c-decl-id-start))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
745 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
746 (while (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
747 pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
748 (< (point) limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
749 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
750 (let (got-identifier) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
751 (setq paren-depth 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
752 ;; Skip over type decl prefix operators. (Note similar |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
753 ;; code in `c-font-lock-declarations'.) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
754 (while (and (looking-at c-type-decl-prefix-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
755 (if (and (c-major-mode-is 'c++-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
756 (match-beginning 2)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
757 ;; If the second submatch matches in C++ then |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
758 ;; we're looking at an identifier that's a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
759 ;; prefix only if it specifies a member pointer. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
760 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
761 (setq id-start (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
762 (c-forward-name) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
763 (if (looking-at "\\(::\\)") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
764 ;; We only check for a trailing "::" and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
765 ;; let the "*" that should follow be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
766 ;; matched in the next round. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
767 t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
768 ;; It turned out to be the real identifier, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
769 ;; so flag that and stop. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
770 (setq got-identifier t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
771 nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
772 t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
773 (if (eq (char-after) ?\() |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
774 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
775 (setq paren-depth (1+ paren-depth)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
776 (forward-char)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
777 (goto-char (match-end 1))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
778 (c-forward-syntactic-ws)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
779 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
780 ;; If we didn't pass the identifier above already, do it now. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
781 (unless got-identifier |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
782 (setq id-start (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
783 (c-forward-name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
784 (setq id-end (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
785 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
786 (/= id-end pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
787 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
788 ;; Skip out of the parens surrounding the identifier. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
789 (or (= paren-depth 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
790 (c-safe (goto-char (scan-lists (point) 1 paren-depth)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
791 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
792 (<= (point) limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
793 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
794 ;; Search syntactically to the end of the declarator (";", |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
795 ;; ",", ")", ">" (for <> arglists), eob etc) or to the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
796 ;; beginning of an initializer or function prototype ("=" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
797 ;; or "\\s\("). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
798 (c-syntactic-re-search-forward |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
799 "[\];,\{\}\[\)>]\\|\\'\\|\\(=\\|\\(\\s\(\\)\\)" limit t t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
800 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
801 (setq next-pos (match-beginning 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
802 id-face (if (match-beginning 2) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
803 'font-lock-function-name-face |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
804 'font-lock-variable-name-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
805 got-init (match-beginning 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
806 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
807 (if types |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
808 ;; Register and fontify the identifer as a type. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
809 (let ((c-promote-possible-types t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
810 (goto-char id-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
811 (c-forward-type)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
812 ;; Fontify the last symbol in the identifier if it isn't fontified |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
813 ;; already. The check is necessary only in certain cases where this |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
814 ;; function is used "sloppily", e.g. in `c-simple-decl-matchers'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
815 (when (and c-last-identifier-range |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
816 (not (get-text-property (car c-last-identifier-range) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
817 'face))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
818 (c-put-font-lock-face (car c-last-identifier-range) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
819 (cdr c-last-identifier-range) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
820 id-face))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
821 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
822 (goto-char next-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
823 (setq pos nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
824 (when list |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
825 ;; Jump past any initializer or function prototype to see if |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
826 ;; there's a ',' to continue at. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
827 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
828 (cond ((eq id-face 'font-lock-function-name-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
829 ;; Skip a parenthesized initializer (C++) or a function |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
830 ;; prototype. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
831 (if (c-safe (c-forward-sexp 1) t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
832 (c-forward-syntactic-ws limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
833 (goto-char limit))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
834 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
835 (got-init |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
836 ;; Skip an initializer expression. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
837 (if (c-syntactic-re-search-forward "[;,]" limit 'move t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
838 (backward-char))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
839 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
840 (t (c-forward-syntactic-ws limit))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
841 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
842 ;; If a ',' is found we set pos to the next declarator and iterate. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
843 (when (and (< (point) limit) (looking-at ",")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
844 (c-put-char-property (point) 'c-type separator-prop) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
845 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
846 (c-forward-syntactic-ws limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
847 (setq pos (point)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
848 nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
849 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
850 (defconst c-font-lock-maybe-decl-faces |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
851 ;; List of faces that might be put at the start of a type when |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
852 ;; `c-font-lock-declarations' runs. This needs to be evaluated to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
853 ;; ensure that face name aliases in Emacs are resolved. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
854 (list nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
855 font-lock-type-face |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
856 c-reference-face-name |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
857 font-lock-keyword-face)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
858 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
859 ;; Macro used inside `c-font-lock-declarations'. It ought to be a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
860 ;; defsubst or perhaps even a defun, but it contains lots of free |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
861 ;; variables that refer to things inside `c-font-lock-declarations'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
862 (defmacro c-fl-shift-type-backward (&optional short) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
863 ;; `c-font-lock-declarations' can consume an arbitrary length list |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
864 ;; of types when parsing a declaration, which means that it |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
865 ;; sometimes consumes the identifier in the declaration as a type. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
866 ;; This is used to "backtrack" and make the last type be treated |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
867 ;; as an identifier instead. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
868 `(progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
869 ,(unless short |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
870 ;; These identifiers are bound only in the inner let. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
871 '(setq identifier-type at-type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
872 identifier-start type-start |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
873 identifier-end type-end)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
874 (if (setq at-type (if (eq prev-at-type 'prefix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
875 t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
876 prev-at-type)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
877 (setq type-start prev-type-start |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
878 type-end prev-type-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
879 (setq type-start start-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
880 type-end start-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
881 ,(unless short |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
882 ;; These identifiers are bound only in the inner let. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
883 '(setq start type-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
884 got-parens nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
885 got-identifier t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
886 got-suffix t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
887 got-suffix-after-parens t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
888 paren-depth 0)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
889 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
890 (defun c-font-lock-declarations (limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
891 ;; Fontify all the declarations and casts from the point to LIMIT. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
892 ;; Assumes that strings and comments have been fontified already. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
893 ;; Nil is always returned. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
894 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
895 ;; This function can make hidden buffer changes, but the font-lock |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
896 ;; context covers that. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
897 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
898 ;;(message "c-font-lock-declarations search from %s to %s" (point) limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
899 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
900 (save-restriction |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
901 (let (start-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
902 c-disallow-comma-in-<>-arglists |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
903 ;; Nonzero if the `c-decl-prefix-re' match is in an arglist context, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
904 ;; as opposed to a statement-level context. The major difference is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
905 ;; that "," works as declaration delimiter in an arglist context, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
906 ;; whereas it only separates declarators in the same declaration in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
907 ;; a statement context. If it's nonzero then the value is the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
908 ;; matched char, e.g. ?\( or ?,. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
909 arglist-match |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
910 ;; 'decl if we're in an arglist containing declarations (but if |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
911 ;; `c-recognize-paren-inits' is set it might also be an initializer |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
912 ;; arglist), '<> if the arglist is of angle bracket type, 'other if |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
913 ;; it's some other arglist, or nil if not in an arglist at all. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
914 arglist-type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
915 ;; Set to the result of `c-forward-type'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
916 at-type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
917 ;; These record the start and end of the type or possible type found |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
918 ;; by `c-forward-type'. `type-start' is at the start of the first |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
919 ;; type token, and `type-end' is at the start of the first token |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
920 ;; after the type (and after any specifiers). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
921 type-start type-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
922 ;; These store `at-type', `type-start' and `type-end' of the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
923 ;; identifier before the one in those variables. The previous |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
924 ;; identifier might turn out to be the real type in a declaration if |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
925 ;; the last one has to be the declarator in it. If `prev-at-type' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
926 ;; is nil then the other variables have undefined values. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
927 prev-at-type prev-type-start prev-type-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
928 ;; Whether we've found a declaration or a cast. We might know this |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
929 ;; before we've found the type in it. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
930 at-decl-or-cast |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
931 ;; Set when we need to back up to parse this as a declaration but |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
932 ;; not as a cast. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
933 backup-if-not-cast |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
934 ;; Set if we've found a "typedef" specifier. The identifiers in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
935 ;; declaration are then fontified as types. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
936 at-typedef |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
937 ;; Set if we've found a specifier that can start a declaration where |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
938 ;; there's no type. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
939 maybe-typeless |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
940 ;; The position of the next token after the closing paren of the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
941 ;; last fontified cast. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
942 last-cast-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
943 ;; The same for the currently investigated cast. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
944 cast-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
945 ;; The maximum of the end positions of all the checked type decl |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
946 ;; expressions in the successfully identified declarations. The |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
947 ;; position might be either before or after the syntactic whitespace |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
948 ;; following the last token in the type decl expression. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
949 (max-type-decl-end 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
950 ;; Same as `max-type-decl-*', but used when we're before |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
951 ;; `token-pos'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
952 (max-type-decl-end-before-token 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
953 ;; Allow recording of identifier ranges in `c-forward-type' etc for |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
954 ;; later fontification. Not using `c-fontify-types-and-refs' here |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
955 ;; since the ranges should be fontified selectively only when a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
956 ;; declaration or cast has been successfully recognized. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
957 c-record-type-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
958 c-record-ref-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
959 ;; The font-lock package in Emacs is known to clobber |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
960 ;; `parse-sexp-lookup-properties' (when it exists). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
961 (parse-sexp-lookup-properties |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
962 (cc-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
963 (boundp 'parse-sexp-lookup-properties)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
964 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
965 ;; Below we fontify a whole declaration even when it crosses the limit, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
966 ;; to avoid gaps when lazy-lock fontifies the file a screenful at a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
967 ;; time. That is however annoying during editing, e.g. the following is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
968 ;; a common situation while the first line is being written: |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
969 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
970 ;; my_variable |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
971 ;; some_other_variable = 0; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
972 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
973 ;; font-lock will put the limit at the beginning of the second line |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
974 ;; here, and if we go past it we'll fontify "my_variable" as a type and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
975 ;; "some_other_variable" as an identifier, and the latter will not |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
976 ;; correct itself until the second line is changed. To avoid that we |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
977 ;; narrow to the limit if the region to fontify is a single line. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
978 (when (<= limit (c-point 'bonl)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
979 (narrow-to-region |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
980 (point-min) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
981 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
982 ;; Narrow after any operator chars following the limit though, since |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
983 ;; those characters can be useful in recognizing a declaration (in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
984 ;; particular the '{' that opens a function body after the header). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
985 (goto-char limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
986 (skip-chars-forward c-nonsymbol-chars) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
987 (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
988 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
989 (c-find-decl-spots |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
990 limit |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
991 c-identifier-start |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
992 c-font-lock-maybe-decl-faces |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
993 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
994 (lambda (match-pos inside-macro) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
995 (catch 'false-alarm |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
996 ;; Don't do anything more if we're looking at a keyword |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
997 ;; that can't start a declaration. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
998 (when (and (eq (get-text-property (point) 'face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
999 'font-lock-keyword-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1000 (looking-at c-not-decl-init-keywords)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1001 (throw 'false-alarm t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1002 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1003 ;; Set `arglist-match' and `arglist-type'. Look for "<" for the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1004 ;; sake of C++-style template arglists. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1005 (setq arglist-match (char-before match-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1006 (if (memq arglist-match '(?\( ?, ?\[ ?<)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1007 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1008 ;; Find out the type of the arglist. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1009 (if (<= match-pos (point-min)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1010 (setq arglist-type 'other) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1011 (let ((type (c-get-char-property (1- match-pos) 'c-type))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1012 (cond ((eq type 'c-decl-arg-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1013 ;; Got a cached hit in a declaration arglist. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1014 (setq arglist-type 'decl)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1015 ((or (eq type 'c-<>-arg-sep) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1016 (eq arglist-match ?<)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1017 ;; Inside an angle bracket arglist. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1018 (setq arglist-type '<>)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1019 (type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1020 ;; Got a cached hit in some other type of arglist. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1021 (setq arglist-type 'other)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1022 ((if inside-macro |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1023 (< match-pos max-type-decl-end-before-token) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1024 (< match-pos max-type-decl-end)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1025 ;; The point is within the range of a previously |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1026 ;; encountered type decl expression, so the arglist |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1027 ;; is probably one that contains declarations. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1028 ;; However, if `c-recognize-paren-inits' is set it |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1029 ;; might also be an initializer arglist. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1030 (setq arglist-type 'decl) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1031 ;; The result of this check is cached with a char |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1032 ;; property on the match token, so that we can look |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1033 ;; it up again when refontifying single lines in a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1034 ;; multiline declaration. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1035 (c-put-char-property (1- match-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1036 'c-type 'c-decl-arg-start)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1037 (t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1038 (setq arglist-type 'other))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1039 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1040 (setq arglist-match nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1041 arglist-type nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1042 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1043 (setq at-type nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1044 at-decl-or-cast nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1045 backup-if-not-cast nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1046 at-typedef nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1047 maybe-typeless nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1048 c-record-type-identifiers t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1049 c-record-ref-identifiers nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1050 ;; `start-pos' is used below to point to the start of the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1051 ;; first type, i.e. after any leading specifiers. It might |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1052 ;; also point at the beginning of the preceding syntactic |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1053 ;; whitespace. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1054 start-pos (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1055 ;; If we're in a normal arglist context we don't want to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1056 ;; recognize commas in nested angle bracket arglists since |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1057 ;; those commas could be part of our own arglist. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1058 c-disallow-comma-in-<>-arglists |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1059 (and c-recognize-<>-arglists |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1060 (eq arglist-type 'other))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1061 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1062 (when (and c-disallow-comma-in-<>-arglists |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1063 (/= arglist-match ?,)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1064 ;; We're standing at the start of a normal arglist so remove any |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1065 ;; angle bracket arglists containing commas that's been |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1066 ;; recognized inside it by the preceding slightly opportunistic |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1067 ;; scan in `c-font-lock-<>-arglists'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1068 (while (and (c-syntactic-re-search-forward |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1069 c-opt-<>-arglist-start-in-paren nil t t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1070 (match-beginning 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1071 (backward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1072 (when (save-match-data |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1073 (and (c-get-char-property (point) 'syntax-table) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1074 (not (c-forward-<>-arglist nil t)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1075 (c-remove-font-lock-face (match-beginning 2) (match-end 2)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1076 (goto-char start-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1077 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1078 ;; Check for a type, but be prepared to skip over leading |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1079 ;; specifiers like "static". Unknown symbols are treated as |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1080 ;; possible types, but they could also be specifiers disguised |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1081 ;; through macros like __INLINE__, so we recognize both types and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1082 ;; known specifiers after them too. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1083 (while (let ((start (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1084 (res (unless (eq at-type t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1085 ;; Don't look for a type if we already found a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1086 ;; positive one; we only loop for the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1087 ;; `c-specifier-key' check then. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1088 (c-forward-type)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1089 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1090 (when res |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1091 ;; Found a known or possible type or a prefix of a known |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1092 ;; type. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1093 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1094 (when at-type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1095 ;; Got two identifiers with nothing but whitespace |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1096 ;; between them. That can only happen in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1097 ;; declarations. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1098 (setq at-decl-or-cast t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1099 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1100 (when (eq at-type 'found) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1101 ;; If the previous identifier is a found type we |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1102 ;; record it as a real one; it might be some sort of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1103 ;; alias for a prefix like "unsigned". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1104 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1105 (goto-char type-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1106 (let ((c-promote-possible-types t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1107 (c-forward-type))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1108 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1109 (setq prev-at-type at-type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1110 prev-type-start type-start |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1111 prev-type-end type-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1112 at-type res |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1113 type-start start |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1114 type-end (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1115 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1116 ;; If the type isn't known we continue so that we'll |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1117 ;; jump over all specifiers and type identifiers. The |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1118 ;; reason to do this for a known type prefix is to make |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1119 ;; things like "unsigned INT16" work. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1120 (setq res (not (eq res t)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1121 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1122 (if (looking-at c-specifier-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1123 ;; Found a known specifier keyword. The specifier |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1124 ;; keywords are restrictive, so we check for them |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1125 ;; anywhere inside or around the type(s). We thereby |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1126 ;; avoid having special cases for specifiers like MSVC |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1127 ;; '__declspec' which can come after the type. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1128 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1129 (setq at-decl-or-cast t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1130 (let ((kwd-sym (c-keyword-sym (match-string 1)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1131 (when (c-keyword-member |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1132 kwd-sym 'c-typedef-decl-kwds) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1133 (setq at-typedef t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1134 (when (c-keyword-member |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1135 kwd-sym 'c-typeless-decl-kwds) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1136 (setq maybe-typeless t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1137 (c-forward-keyword-clause) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1138 ;; Move type-end forward if we've passed a type, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1139 ;; otherwise move start-pos forward. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1140 (if at-type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1141 (setq type-end (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1142 (setq start-pos (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1143 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1144 res))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1145 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1146 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1147 ((eq at-type 'prefix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1148 ;; A prefix type is itself a primitive type when it's not |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1149 ;; followed by another type. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1150 (setq at-type t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1151 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1152 ((not at-type) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1153 ;; Got no type but set things up to continue anyway to handle the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1154 ;; various cases when a declaration doesn't start with a type. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1155 (setq type-end start-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1156 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1157 ((and (eq at-type 'maybe) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1158 (c-major-mode-is 'c++-mode)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1159 ;; If it's C++ then check if the last "type" ends on the form |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1160 ;; "foo::foo" or "foo::~foo", i.e. if it's the name of a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1161 ;; (con|de)structor. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1162 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1163 (let (name end-2 end-1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1164 (goto-char type-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1165 (c-backward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1166 (setq end-2 (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1167 (when (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1168 (c-simple-skip-symbol-backward) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1169 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1170 (setq name |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1171 (buffer-substring-no-properties (point) end-2)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1172 ;; Cheating in the handling of syntactic ws below. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1173 (< (skip-chars-backward ":~ \t\n\r\v\f") 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1174 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1175 (setq end-1 (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1176 (c-simple-skip-symbol-backward)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1177 (>= (point) type-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1178 (equal (buffer-substring-no-properties (point) end-1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1179 name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1180 ;; It is a (con|de)structor name. In that case the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1181 ;; declaration is typeless so zap out any preceding |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1182 ;; identifier(s) that we might have taken as types. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1183 (goto-char type-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1184 (setq at-type nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1185 prev-at-type nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1186 type-end type-start)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1187 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1188 ;; Check for and step over a type decl expression after the thing |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1189 ;; that is or might be a type. This can't be skipped since we need |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1190 ;; the correct end position of the declarator for |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1191 ;; `max-type-decl-end-*'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1192 (let ((start (point)) (paren-depth 0) pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1193 ;; True if there's a non-open-paren match of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1194 ;; `c-type-decl-prefix-key'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1195 got-prefix |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1196 ;; True if the declarator is surrounded by a parenthesis pair. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1197 got-parens |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1198 ;; True if there is an identifier in the declarator. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1199 got-identifier |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1200 ;; True if there's a non-close-paren match of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1201 ;; `c-type-decl-suffix-key'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1202 got-suffix |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1203 ;; True if there's a prefix or suffix match outside the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1204 ;; outermost paren pair that surrounds the declarator. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1205 got-prefix-before-parens |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1206 got-suffix-after-parens |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1207 ;; True if we've parsed the type decl to a token that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1208 ;; is known to end declarations in this context. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1209 at-decl-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1210 ;; The earlier values of `at-type', `type-start' and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1211 ;; `type-end' if we've shifted the type backwards. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1212 identifier-type identifier-start identifier-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1213 (goto-char type-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1214 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1215 ;; Skip over type decl prefix operators. (Note similar code in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1216 ;; `c-font-lock-declarators'.) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1217 (while (and (looking-at c-type-decl-prefix-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1218 (if (and (c-major-mode-is 'c++-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1219 (match-beginning 2)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1220 ;; If the second submatch matches in C++ then |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1221 ;; we're looking at an identifier that's a prefix |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1222 ;; only if it specifies a member pointer. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1223 (when (setq got-identifier (c-forward-name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1224 (if (looking-at "\\(::\\)") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1225 ;; We only check for a trailing "::" and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1226 ;; let the "*" that should follow be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1227 ;; matched in the next round. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1228 (progn (setq got-identifier nil) t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1229 ;; It turned out to be the real identifier, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1230 ;; so stop. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1231 nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1232 t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1233 (if (eq (char-after) ?\() |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1234 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1235 (setq paren-depth (1+ paren-depth)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1236 (forward-char)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1237 (unless got-prefix-before-parens |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1238 (setq got-prefix-before-parens (= paren-depth 0))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1239 (setq got-prefix t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1240 (goto-char (match-end 1))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1241 (c-forward-syntactic-ws)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1242 (setq got-parens (> paren-depth 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1243 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1244 ;; Skip over an identifier. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1245 (or got-identifier |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1246 (and (looking-at c-identifier-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1247 (setq got-identifier (c-forward-name)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1248 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1249 ;; Skip over type decl suffix operators. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1250 (while (if (looking-at c-type-decl-suffix-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1251 (if (eq (char-after) ?\)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1252 (when (> paren-depth 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1253 (setq paren-depth (1- paren-depth)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1254 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1255 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1256 (when (if (save-match-data (looking-at "\\s\(")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1257 (c-safe (c-forward-sexp 1) t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1258 (goto-char (match-end 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1259 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1260 (unless got-suffix-after-parens |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1261 (setq got-suffix-after-parens (= paren-depth 0))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1262 (setq got-suffix t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1263 ;; No suffix matched. We might have matched the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1264 ;; identifier as a type and the open paren of a function |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1265 ;; arglist as a type decl prefix. In that case we |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1266 ;; should "backtrack": Reinterpret the last type as the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1267 ;; identifier, move out of the arglist and continue |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1268 ;; searching for suffix operators. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1269 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1270 ;; Do this even if there's no preceding type, to cope |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1271 ;; with old style function declarations in K&R C, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1272 ;; (con|de)structors in C++ and `c-typeless-decl-kwds' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1273 ;; style declarations. That isn't applicable in an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1274 ;; arglist context, though. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1275 (when (and (= paren-depth 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1276 (not got-prefix-before-parens) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1277 (not (eq at-type t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1278 (or prev-at-type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1279 maybe-typeless |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1280 (when c-recognize-typeless-decls |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1281 (not arglist-type))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1282 (setq pos (c-up-list-forward (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1283 (eq (char-before pos) ?\))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1284 (c-fl-shift-type-backward) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1285 (goto-char pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1286 t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1287 (c-forward-syntactic-ws)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1288 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1289 (when (and maybe-typeless |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1290 (not got-identifier) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1291 (not got-prefix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1292 at-type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1293 (not (eq at-type t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1294 ;; Have found no identifier but `c-typeless-decl-kwds' has |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1295 ;; matched so we know we're inside a declaration. The |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1296 ;; preceding type must be the identifier instead. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1297 (c-fl-shift-type-backward)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1298 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1299 (setq |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1300 at-decl-or-cast |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1301 (catch 'at-decl-or-cast |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1302 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1303 (when (> paren-depth 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1304 ;; Encountered something inside parens that isn't matched by |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1305 ;; the `c-type-decl-*' regexps, so it's not a type decl |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1306 ;; expression. Try to skip out to the same paren depth to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1307 ;; not confuse the cast check below. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1308 (c-safe (goto-char (scan-lists (point) 1 paren-depth))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1309 (throw 'at-decl-or-cast nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1310 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1311 (setq at-decl-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1312 (looking-at (cond ((eq arglist-type '<>) "[,>]") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1313 (arglist-type "[,\)]") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1314 (t "[,;]")))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1315 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1316 ;; Now we've collected info about various characteristics of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1317 ;; the construct we're looking at. Below follows a decision |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1318 ;; tree based on that. It's ordered to check more certain |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1319 ;; signs before less certain ones. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1320 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1321 (if got-identifier |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1322 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1323 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1324 (when (and (or at-type maybe-typeless) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1325 (not (or got-prefix got-parens))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1326 ;; Got another identifier directly after the type, so |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1327 ;; it's a declaration. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1328 (throw 'at-decl-or-cast t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1329 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1330 (when (and got-parens |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1331 (not got-prefix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1332 (not got-suffix-after-parens) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1333 (or prev-at-type maybe-typeless)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1334 ;; Got a declaration of the form "foo bar (gnu);" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1335 ;; where we've recognized "bar" as the type and "gnu" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1336 ;; as the declarator. In this case it's however more |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1337 ;; likely that "bar" is the declarator and "gnu" a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1338 ;; function argument or initializer (if |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1339 ;; `c-recognize-paren-inits' is set), since the parens |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1340 ;; around "gnu" would be superfluous if it's a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1341 ;; declarator. Shift the type one step backward. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1342 (c-fl-shift-type-backward))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1343 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1344 ;; Found no identifier. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1345 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1346 (if prev-at-type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1347 (when (or (= (point) start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1348 (and got-suffix |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1349 (not got-prefix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1350 (not got-parens))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1351 ;; Got two types after each other, so if this isn't a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1352 ;; cast then the latter probably is the identifier and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1353 ;; we should back up to the previous type. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1354 (setq backup-if-not-cast t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1355 (throw 'at-decl-or-cast t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1356 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1357 (when (eq at-type t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1358 ;; If the type is known we know that there can't be any |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1359 ;; identifier somewhere else, and it's only in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1360 ;; declarations in e.g. function prototypes and in casts |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1361 ;; that the identifier may be left out. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1362 (throw 'at-decl-or-cast t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1363 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1364 (when (= (point) start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1365 ;; Only got a single identifier (parsed as a type so |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1366 ;; far). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1367 (if (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1368 ;; Check that the identifier isn't at the start of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1369 ;; an expression. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1370 at-decl-end |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1371 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1372 ((eq arglist-type 'decl) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1373 ;; Inside an arglist that contains declarations. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1374 ;; If K&R style declarations and parenthesis |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1375 ;; style initializers aren't allowed then the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1376 ;; single identifier must be a type, else we |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1377 ;; require that it's known or found (primitive |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1378 ;; types are handled above). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1379 (or (and (not c-recognize-knr-p) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1380 (not c-recognize-paren-inits)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1381 (memq at-type '(known found)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1382 ((eq arglist-type '<>) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1383 ;; Inside a template arglist. Accept known and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1384 ;; found types; other identifiers could just as |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1385 ;; well be constants in C++. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1386 (memq at-type '(known found))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1387 (throw 'at-decl-or-cast t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1388 (throw 'at-decl-or-cast nil)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1389 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1390 (if (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1391 got-parens |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1392 (not got-prefix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1393 (not arglist-type) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1394 (not (eq at-type t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1395 (or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1396 prev-at-type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1397 maybe-typeless |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1398 (when c-recognize-typeless-decls |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1399 (or (not got-suffix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1400 (not (looking-at |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1401 c-after-suffixed-type-maybe-decl-key)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1402 ;; Got an empty paren pair and a preceding type that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1403 ;; probably really is the identifier. Shift the type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1404 ;; backwards to make the last one the identifier. This |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1405 ;; is analogous to the "backtracking" done inside the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1406 ;; `c-type-decl-suffix-key' loop above. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1407 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1408 ;; Exception: In addition to the conditions in that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1409 ;; "backtracking" code, do not shift backward if we're |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1410 ;; not looking at either `c-after-suffixed-type-decl-key' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1411 ;; or "[;,]". Since there's no preceding type, the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1412 ;; shift would mean that the declaration is typeless. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1413 ;; But if the regexp doesn't match then we will simply |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1414 ;; fall through in the tests below and not recognize it |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1415 ;; at all, so it's better to try it as an abstract |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1416 ;; declarator instead. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1417 (c-fl-shift-type-backward) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1418 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1419 ;; Still no identifier. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1420 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1421 (when (and got-prefix (or got-parens got-suffix)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1422 ;; Require `got-prefix' together with either |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1423 ;; `got-parens' or `got-suffix' to recognize it as an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1424 ;; abstract declarator: `got-parens' only is probably an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1425 ;; empty function call. `got-suffix' only can build an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1426 ;; ordinary expression together with the preceding |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1427 ;; identifier which we've taken as a type. We could |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1428 ;; actually accept on `got-prefix' only, but that can |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1429 ;; easily occur temporarily while writing an expression |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1430 ;; so we avoid that case anyway. We could do a better |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1431 ;; job if we knew the point when the fontification was |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1432 ;; invoked. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1433 (throw 'at-decl-or-cast t)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1434 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1435 (when at-decl-or-cast |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1436 ;; By now we've located the type in the declaration that we |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1437 ;; know we're in. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1438 (throw 'at-decl-or-cast t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1439 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1440 (when (and got-identifier |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1441 (not arglist-type) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1442 (looking-at c-after-suffixed-type-decl-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1443 (if (and got-parens |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1444 (not got-prefix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1445 (not got-suffix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1446 (not (eq at-type t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1447 ;; Shift the type backward in the case that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1448 ;; there's a single identifier inside parens. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1449 ;; That can only occur in K&R style function |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1450 ;; declarations so it's more likely that it |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1451 ;; really is a function call. Therefore we |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1452 ;; only do this after |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1453 ;; `c-after-suffixed-type-decl-key' has |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1454 ;; matched. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1455 (progn (c-fl-shift-type-backward) t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1456 got-suffix-after-parens)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1457 ;; A declaration according to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1458 ;; `c-after-suffixed-type-decl-key'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1459 (throw 'at-decl-or-cast t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1460 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1461 (when (and (or got-prefix (not got-parens)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1462 (memq at-type '(t known))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1463 ;; It's a declaration if a known type precedes it and it |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1464 ;; can't be a function call. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1465 (throw 'at-decl-or-cast t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1466 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1467 ;; If we get here we can't tell if this is a type decl or a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1468 ;; normal expression by looking at it alone. (That's under |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1469 ;; the assumption that normal expressions always can look like |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1470 ;; type decl expressions, which isn't really true but the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1471 ;; cases where it doesn't hold are so uncommon (e.g. some |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1472 ;; placements of "const" in C++) it's not worth the effort to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1473 ;; look for them.) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1474 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1475 (unless (or at-decl-end (looking-at "=[^=]")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1476 ;; If this is a declaration it should end here or its |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1477 ;; initializer(*) should start here, so check for allowed |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1478 ;; separation tokens. Note that this rule doesn't work |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1479 ;; e.g. with a K&R arglist after a function header. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1480 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1481 ;; *) Don't check for C++ style initializers using parens |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1482 ;; since those already have been matched as suffixes. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1483 (throw 'at-decl-or-cast nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1484 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1485 ;; Below are tests that only should be applied when we're |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1486 ;; certain to not have parsed halfway through an expression. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1487 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1488 (when (memq at-type '(t known)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1489 ;; The expression starts with a known type so treat it as a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1490 ;; declaration. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1491 (throw 'at-decl-or-cast t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1492 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1493 (when (and (c-major-mode-is 'c++-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1494 ;; In C++ we check if the identifier is a known |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1495 ;; type, since (con|de)structors use the class name |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1496 ;; as identifier. We've always shifted over the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1497 ;; identifier as a type and then backed up again in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1498 ;; this case. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1499 identifier-type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1500 (or (eq identifier-type 'found) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1501 (and (eq (char-after identifier-start) ?~) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1502 ;; `at-type' probably won't be 'found for |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1503 ;; destructors since the "~" is then part |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1504 ;; of the type name being checked against |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1505 ;; the list of known types, so do a check |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1506 ;; without that operator. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1507 (c-check-type (1+ identifier-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1508 identifier-end)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1509 (throw 'at-decl-or-cast t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1510 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1511 (if got-identifier |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1512 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1513 (when (and got-prefix-before-parens |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1514 at-type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1515 (or at-decl-end (looking-at "=[^=]")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1516 (not arglist-type) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1517 (not got-suffix)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1518 ;; Got something like "foo * bar;". Since we're not |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1519 ;; inside an arglist it would be a meaningless |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1520 ;; expression because the result isn't used. We |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1521 ;; therefore choose to recognize it as a declaration. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1522 ;; Do not allow a suffix since it could then be a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1523 ;; function call. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1524 (throw 'at-decl-or-cast t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1525 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1526 (when (and (or got-suffix-after-parens |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1527 (looking-at "=[^=]")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1528 (eq at-type 'found) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1529 (not (eq arglist-type 'other))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1530 ;; Got something like "a (*b) (c);" or "a (b) = c;". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1531 ;; It could be an odd expression or it could be a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1532 ;; declaration. Treat it as a declaration if "a" has |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1533 ;; been used as a type somewhere else (if it's a known |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1534 ;; type we won't get here). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1535 (throw 'at-decl-or-cast t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1536 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1537 (when (and arglist-type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1538 (or got-prefix |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1539 (and (eq arglist-type 'decl) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1540 (not c-recognize-paren-inits) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1541 (or got-parens got-suffix)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1542 ;; Got a type followed by an abstract declarator. If |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1543 ;; `got-prefix' is set it's something like "a *" without |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1544 ;; anything after it. If `got-parens' or `got-suffix' is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1545 ;; set it's "a()", "a[]", "a()[]", or similar, which we |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1546 ;; accept only if the context rules out expressions. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1547 (throw 'at-decl-or-cast t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1548 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1549 ;; If we had a complete symbol table here (which rules out |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1550 ;; `c-found-types') we should return t due to the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1551 ;; disambiguation rule (in at least C++) that anything that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1552 ;; can be parsed as a declaration is a declaration. Now we're |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1553 ;; being more defensive and prefer to highlight things like |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1554 ;; "foo (bar);" as a declaration only if we're inside an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1555 ;; arglist that contains declarations. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1556 (eq arglist-type 'decl)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1557 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1558 ;; Point is now after the type decl expression. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1559 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1560 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1561 ;; Check for a cast. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1562 ((save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1563 (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1564 c-cast-parens |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1565 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1566 ;; Should be the first type/identifier in a cast paren. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1567 (memq arglist-match c-cast-parens) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1568 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1569 ;; The closing paren should follow. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1570 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1571 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1572 (looking-at "\\s\)")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1573 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1574 ;; There should be a primary expression after it. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1575 (let (pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1576 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1577 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1578 (setq cast-end (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1579 (and (looking-at c-primary-expr-regexp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1580 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1581 (setq pos (match-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1582 (or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1583 ;; Check if the expression begins with a prefix |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1584 ;; keyword. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1585 (match-beginning 2) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1586 (if (match-beginning 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1587 ;; Expression begins with an ambiguous operator. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1588 ;; Treat it as a cast if it's a type decl or if |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1589 ;; we've recognized the type somewhere else. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1590 (or at-decl-or-cast |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1591 (memq at-type '(t known found))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1592 ;; Unless it's a keyword, it's the beginning of a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1593 ;; primary expression. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1594 (not (looking-at c-keywords-regexp))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1595 ;; If `c-primary-expr-regexp' matched a nonsymbol |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1596 ;; token, check that it matched a whole one so that we |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1597 ;; don't e.g. confuse the operator '-' with '->'. It's |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1598 ;; ok if it matches further, though, since it e.g. can |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1599 ;; match the float '.5' while the operator regexp only |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1600 ;; matches '.'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1601 (or (not (looking-at c-nonsymbol-token-regexp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1602 (<= (match-end 0) pos)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1603 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1604 ;; There should either be a cast before it or something that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1605 ;; isn't an identifier or close paren. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1606 (/= match-pos 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1607 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1608 (goto-char (1- match-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1609 (or (eq (point) last-cast-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1610 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1611 (c-backward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1612 (if (< (skip-syntax-backward "w_") 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1613 ;; It's a symbol. Accept it only if it's one of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1614 ;; the keywords that can precede an expression |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1615 ;; (without surrounding parens). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1616 (looking-at c-simple-stmt-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1617 (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1618 ;; Check that it isn't a close paren (block close |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1619 ;; is ok, though). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1620 (not (memq (char-before) '(?\) ?\]))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1621 ;; Check that it isn't a nonsymbol identifier. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1622 (not (c-on-identifier))))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1623 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1624 ;; Handle the cast. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1625 (setq last-cast-end cast-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1626 (when (and at-type (not (eq at-type t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1627 (let ((c-promote-possible-types t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1628 (goto-char type-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1629 (c-forward-type)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1630 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1631 (at-decl-or-cast |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1632 ;; We're at a declaration. Highlight the type and the following |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1633 ;; declarators. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1634 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1635 (when backup-if-not-cast |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1636 (c-fl-shift-type-backward t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1637 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1638 (when (and (eq arglist-type 'decl) (looking-at ",")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1639 ;; Make sure to propagate the `c-decl-arg-start' property to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1640 ;; the next argument if it's set in this one, to cope with |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1641 ;; interactive refontification. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1642 (c-put-char-property (point) 'c-type 'c-decl-arg-start)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1643 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1644 ;; Set `max-type-decl-end' or `max-type-decl-end-before-token' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1645 ;; under the assumption that we're after the first type decl |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1646 ;; expression in the declaration now. That's not really true; we |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1647 ;; could also be after a parenthesized initializer expression in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1648 ;; C++, but this is only used as a last resort to slant ambiguous |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1649 ;; expression/declarations, and overall it's worth the risk to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1650 ;; occasionally fontify an expression as a declaration in an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1651 ;; initializer expression compared to getting ambiguous things in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1652 ;; normal function prototypes fontified as expressions. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1653 (if inside-macro |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1654 (when (> (point) max-type-decl-end-before-token) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1655 (setq max-type-decl-end-before-token (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1656 (when (> (point) max-type-decl-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1657 (setq max-type-decl-end (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1658 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1659 (when (and at-type (not (eq at-type t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1660 (let ((c-promote-possible-types t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1661 (goto-char type-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1662 (c-forward-type))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1663 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1664 (goto-char type-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1665 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1666 (let ((decl-list |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1667 (if arglist-type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1668 ;; Should normally not fontify a list of declarators |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1669 ;; inside an arglist, but the first argument in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1670 ;; ';' separated list of a "for" statement is an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1671 ;; exception. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1672 (when (and (eq arglist-match ?\() (/= match-pos 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1673 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1674 (goto-char (1- match-pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1675 (c-backward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1676 (and (c-simple-skip-symbol-backward) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1677 (looking-at c-paren-stmt-key)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1678 t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1679 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1680 ;; Fix the `c-decl-id-start' or `c-decl-type-start' property |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1681 ;; before the first declarator if it's a list. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1682 ;; `c-font-lock-declarators' handles the rest. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1683 (when decl-list |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1684 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1685 (c-backward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1686 (unless (bobp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1687 (c-put-char-property (1- (point)) 'c-type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1688 (if at-typedef |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1689 'c-decl-type-start |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1690 'c-decl-id-start))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1691 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1692 (c-font-lock-declarators (point-max) decl-list at-typedef))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1693 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1694 (t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1695 ;; False alarm. Skip the fontification done below. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1696 (throw 'false-alarm t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1697 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1698 ;; A cast or declaration has been successfully identified, so do |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1699 ;; all the fontification of types and refs that's been recorded by |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1700 ;; the calls to `c-forward-type' and `c-forward-name' above. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1701 (c-fontify-recorded-types-and-refs) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1702 nil))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1703 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1704 nil))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1705 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1706 (c-lang-defconst c-simple-decl-matchers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1707 "Simple font lock matchers for types and declarations. These are used |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1708 on level 2 only and so aren't combined with `c-complex-decl-matchers'." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1709 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1710 t `(;; Objective-C methods. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1711 ,@(when (c-major-mode-is 'objc-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1712 `((,(c-lang-const c-opt-method-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1713 (,(byte-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1714 (lambda (limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1715 (let (;; The font-lock package in Emacs is known to clobber |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1716 ;; `parse-sexp-lookup-properties' (when it exists). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1717 (parse-sexp-lookup-properties |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1718 (cc-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1719 (boundp 'parse-sexp-lookup-properties)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1720 (save-restriction |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1721 (narrow-to-region (point-min) limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1722 (c-font-lock-objc-method))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1723 nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1724 (goto-char (match-end 1)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1725 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1726 ;; Fontify all type names and the identifiers in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1727 ;; declarations they might start. Use eval here since |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1728 ;; `c-known-type-key' gets its value from |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1729 ;; `*-font-lock-extra-types' on mode init. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1730 (eval . (list ,(c-make-font-lock-search-function |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1731 'c-known-type-key |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1732 '(1 'font-lock-type-face t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1733 '((c-font-lock-declarators limit t nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1734 (save-match-data |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1735 (goto-char (match-end 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1736 (c-forward-syntactic-ws)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1737 (goto-char (match-end 1)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1738 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1739 ;; Fontify types preceded by `c-type-prefix-kwds' and the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1740 ;; identifiers in the declarations they might start. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1741 ,@(when (c-lang-const c-type-prefix-kwds) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1742 (let ((prefix-re (c-make-keywords-re nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1743 (c-lang-const c-type-prefix-kwds)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1744 `((,(c-make-font-lock-search-function |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1745 (concat "\\<\\(" prefix-re "\\)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1746 "[ \t\n\r\f\v]+" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1747 "\\(" (c-lang-const c-symbol-key) "\\)") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1748 `(,(+ (c-regexp-opt-depth prefix-re) 2) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1749 'font-lock-type-face t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1750 '((c-font-lock-declarators limit t nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1751 (save-match-data |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1752 (goto-char (match-end 2)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1753 (c-forward-syntactic-ws)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1754 (goto-char (match-end 2)))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1755 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1756 ;; Fontify special declarations that lacks a type. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1757 ,@(when (c-lang-const c-typeless-decl-kwds) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1758 `((,(c-make-font-lock-search-function |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1759 (concat "\\<\\(" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1760 (c-regexp-opt (c-lang-const c-typeless-decl-kwds)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1761 "\\)\\>") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1762 '((c-font-lock-declarators limit t nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1763 (save-match-data |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1764 (goto-char (match-end 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1765 (c-forward-syntactic-ws)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1766 (goto-char (match-end 1))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1767 )) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1768 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1769 (c-lang-defconst c-complex-decl-matchers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1770 "Complex font lock matchers for types and declarations. Used on level |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1771 3 and higher." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1772 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1773 t `(;; Initialize some things before the search functions below. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1774 c-font-lock-complex-decl-prepare |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1775 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1776 ;; Fontify angle bracket arglists like templates in C++. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1777 ,@(when (c-lang-const c-recognize-<>-arglists) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1778 `(c-font-lock-<>-arglists)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1779 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1780 ,@(if (c-major-mode-is 'objc-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1781 ;; Fontify method declarations in Objective-C, but first |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1782 ;; we have to put the `c-decl-end' `c-type' property on |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1783 ;; all the @-style directives that haven't been handled in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1784 ;; `c-basic-matchers-before'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1785 `(,(c-make-font-lock-search-function |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1786 (c-make-keywords-re t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1787 ;; Exclude "@class" since that directive ends with a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1788 ;; semicolon anyway. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1789 (delete "@class" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1790 (append (c-lang-const c-protection-kwds) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1791 (c-lang-const c-other-decl-kwds) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1792 nil))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1793 '((c-put-char-property (1- (match-end 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1794 'c-type 'c-decl-end))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1795 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1796 c-font-lock-objc-methods) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1797 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1798 (when (c-lang-const c-opt-access-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1799 `(,(c-make-font-lock-search-function |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1800 (c-lang-const c-opt-access-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1801 '((c-put-char-property (1- (match-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1802 'c-type 'c-decl-end)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1803 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1804 ;; Fontify all declarations and casts. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1805 c-font-lock-declarations |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1806 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1807 ;; The first two rules here mostly find occurences that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1808 ;; `c-font-lock-declarations' has found already, but not |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1809 ;; declarations containing blocks in the type (see note below). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1810 ;; It's also useful to fontify these everywhere to show e.g. when |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1811 ;; a type keyword is accidentally used as an identifier. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1812 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1813 ;; Fontify basic types. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1814 ,(let ((re (c-make-keywords-re nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1815 (c-lang-const c-primitive-type-kwds)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1816 (if (c-major-mode-is 'pike-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1817 ;; No symbol is a keyword after "->" in Pike. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1818 `(,(concat "\\(\\=\\|\\(\\=\\|[^-]\\)[^>]\\)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1819 "\\<\\(" re "\\)\\>") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1820 3 font-lock-type-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1821 `(,(concat "\\<\\(" re "\\)\\>") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1822 1 'font-lock-type-face))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1823 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1824 ;; Fontify types preceded by `c-type-prefix-kwds'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1825 ,@(when (c-lang-const c-type-prefix-kwds) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1826 `((,(byte-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1827 `(lambda (limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1828 (c-fontify-types-and-refs |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1829 ((c-promote-possible-types t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1830 ;; The font-lock package in Emacs is known to clobber |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1831 ;; `parse-sexp-lookup-properties' (when it exists). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1832 (parse-sexp-lookup-properties |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1833 (cc-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1834 (boundp 'parse-sexp-lookup-properties)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1835 (save-restriction |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1836 ;; Narrow to avoid going past the limit in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1837 ;; `c-forward-type'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1838 (narrow-to-region (point) limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1839 (while (re-search-forward |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1840 ,(concat "\\<\\(" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1841 (c-make-keywords-re nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1842 (c-lang-const c-type-prefix-kwds)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1843 "\\)\\>") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1844 limit t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1845 (unless (c-skip-comments-and-strings limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1846 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1847 ;; Handle prefix declaration specifiers. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1848 (when (looking-at c-specifier-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1849 (c-forward-keyword-clause)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1850 ,(if (c-major-mode-is 'c++-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1851 `(when (and (c-forward-type) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1852 (eq (char-after) ?=)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1853 ;; In C++ we additionally check for a "class |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1854 ;; X = Y" construct which is used in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1855 ;; templates, to fontify Y as a type. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1856 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1857 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1858 (c-forward-type)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1859 `(c-forward-type)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1860 ))))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1861 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1862 ;; Fontify symbols after closing braces as declaration |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1863 ;; identifiers under the assumption that they are part of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1864 ;; declarations like "class Foo { ... } foo;". It's too |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1865 ;; expensive to check this accurately by skipping past the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1866 ;; brace block, so we use the heuristic that it's such a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1867 ;; declaration if the first identifier is on the same line as |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1868 ;; the closing brace. `c-font-lock-declarations' will later |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1869 ;; override it if it turns out to be an new declaration, but |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1870 ;; it will be wrong if it's an expression (see the test |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1871 ;; decls-8.cc). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1872 ,@(when (c-lang-const c-opt-block-decls-with-vars-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1873 `((,(c-make-font-lock-search-function |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1874 (concat "}" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1875 (c-lang-const c-single-line-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1876 "\\(" ; 1 + c-single-line-syntactic-ws-depth |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1877 (c-lang-const c-type-decl-prefix-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1878 "\\|" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1879 (c-lang-const c-symbol-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1880 "\\)") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1881 `((c-font-lock-declarators limit t nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1882 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1883 (c-put-char-property (match-beginning 0) 'c-type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1884 'c-decl-id-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1885 (goto-char (match-beginning |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1886 ,(1+ (c-lang-const |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1887 c-single-line-syntactic-ws-depth))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1888 (goto-char (match-end 0))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1889 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1890 ;; Fontify the type in C++ "new" expressions. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1891 ,@(when (c-major-mode-is 'c++-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1892 `(("\\<new\\>" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1893 (c-font-lock-c++-new)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1894 )) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1895 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1896 (defun c-font-lock-labels (limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1897 ;; Fontify all the declarations from the point to LIMIT. Assumes |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1898 ;; that strings and comments have been fontified already. Nil is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1899 ;; always returned. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1900 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1901 ;; This function can make hidden buffer changes, but the font-lock |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1902 ;; context covers that. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1903 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1904 (let (continue-pos id-start |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1905 ;; The font-lock package in Emacs is known to clobber |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1906 ;; `parse-sexp-lookup-properties' (when it exists). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1907 (parse-sexp-lookup-properties |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1908 (cc-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1909 (boundp 'parse-sexp-lookup-properties)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1910 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1911 (while (re-search-forward ":[^:]" limit t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1912 (setq continue-pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1913 (goto-char (match-beginning 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1914 (unless (c-skip-comments-and-strings limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1915 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1916 (c-backward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1917 (and (setq id-start (c-on-identifier)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1918 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1919 (not (get-text-property id-start 'face)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1920 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1921 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1922 (goto-char id-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1923 (c-backward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1924 (or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1925 ;; Check for a char that precedes a statement. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1926 (memq (char-before) '(?\} ?\{ ?\;)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1927 ;; Check for a preceding label. We exploit the font |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1928 ;; locking made earlier by this function. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1929 (and (eq (char-before) ?:) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1930 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1931 (backward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1932 (c-backward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1933 (not (bobp))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1934 (eq (get-text-property (1- (point)) 'face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1935 c-label-face-name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1936 ;; Check for a keyword that precedes a statement. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1937 (c-after-conditional))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1938 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1939 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1940 ;; Got a label. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1941 (goto-char id-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1942 (looking-at c-symbol-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1943 (c-put-font-lock-face (match-beginning 0) (match-end 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1944 c-label-face-name))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1945 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1946 (goto-char continue-pos)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1947 nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1948 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1949 (c-lang-defconst c-basic-matchers-after |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1950 "Font lock matchers for various things that should be fontified after |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1951 generic casts and declarations are fontified. Used on level 2 and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1952 higher." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1953 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1954 t `(;; Fontify the identifiers inside enum lists. (The enum type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1955 ;; name is handled by `c-simple-decl-matchers' or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1956 ;; `c-complex-decl-matchers' below. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1957 ,@(when (c-lang-const c-brace-id-list-kwds) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1958 `((,(c-make-font-lock-search-function |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1959 (concat |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1960 "\\<\\(" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1961 (c-make-keywords-re nil (c-lang-const c-brace-id-list-kwds)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1962 "\\)\\>" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1963 ;; Disallow various common punctuation chars that can't come |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1964 ;; before the '{' of the enum list, to avoid searching too far. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1965 "[^\]\[{}();,/#=]*" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1966 "{") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1967 '((c-font-lock-declarators limit t nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1968 (save-match-data |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1969 (goto-char (match-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1970 (c-put-char-property (1- (point)) 'c-type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1971 'c-decl-id-start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1972 (c-forward-syntactic-ws)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1973 (goto-char (match-end 0))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1974 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1975 ;; Fontify labels in languages that supports them. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1976 ,@(when (c-lang-const c-label-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1977 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1978 `(;; Fontify labels after goto etc. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1979 ;; (Got three different interpretation levels here, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1980 ;; which makes it a bit complicated: 1) The backquote |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1981 ;; stuff is expanded when compiled or loaded, 2) the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1982 ;; eval form is evaluated at font-lock setup (to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1983 ;; substitute c-label-face-name correctly), and 3) the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1984 ;; resulting structure is interpreted during |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1985 ;; fontification.) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1986 (eval |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1987 . ,(let* ((c-before-label-re |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1988 (c-make-keywords-re nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1989 (c-lang-const c-before-label-kwds)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1990 `(list |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1991 ,(concat "\\<\\(" c-before-label-re "\\)\\>" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1992 "\\s *" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1993 "\\(" ; identifier-offset |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1994 (c-lang-const c-symbol-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1995 "\\)") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1996 (list ,(+ (c-regexp-opt-depth c-before-label-re) 2) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1997 c-label-face-name nil t)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1998 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
1999 ;; Fontify normal labels. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2000 c-font-lock-labels)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2001 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2002 ;; Fontify the clauses after various keywords. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2003 ,@(when (or (c-lang-const c-type-list-kwds) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2004 (c-lang-const c-ref-list-kwds) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2005 (c-lang-const c-colon-type-list-kwds) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2006 (c-lang-const c-paren-type-kwds)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2007 `((,(c-make-font-lock-search-function |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2008 (concat "\\<\\(" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2009 (c-make-keywords-re nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2010 (append (c-lang-const c-type-list-kwds) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2011 (c-lang-const c-ref-list-kwds) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2012 (c-lang-const c-colon-type-list-kwds) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2013 (c-lang-const c-paren-type-kwds))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2014 "\\)\\>") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2015 '((c-fontify-types-and-refs ((c-promote-possible-types t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2016 (c-forward-keyword-clause) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2017 (if (> (point) limit) (goto-char limit)))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2018 )) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2019 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2020 (c-lang-defconst c-matchers-1 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2021 t (c-lang-const c-cpp-matchers)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2022 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2023 (c-lang-defconst c-matchers-2 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2024 t (append (c-lang-const c-matchers-1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2025 (c-lang-const c-basic-matchers-before) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2026 (c-lang-const c-simple-decl-matchers) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2027 (c-lang-const c-basic-matchers-after))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2028 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2029 (c-lang-defconst c-matchers-3 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2030 t (append (c-lang-const c-matchers-1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2031 (c-lang-const c-basic-matchers-before) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2032 (c-lang-const c-complex-decl-matchers) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2033 (c-lang-const c-basic-matchers-after))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2034 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2035 (defun c-compose-keywords-list (base-list) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2036 ;; Incorporate the font lock keyword lists according to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2037 ;; `c-doc-comment-style' on the given keyword list and return it. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2038 ;; This is used in the function bindings of the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2039 ;; `*-font-lock-keywords-*' symbols since we have to build the list |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2040 ;; when font-lock is initialized. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2041 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2042 (unless (memq c-doc-face-name c-literal-faces) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2043 (setq c-literal-faces (cons c-doc-face-name c-literal-faces))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2044 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2045 (let* ((doc-keywords |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2046 (if (consp (car-safe c-doc-comment-style)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2047 (cdr-safe (or (assq c-buffer-is-cc-mode c-doc-comment-style) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2048 (assq 'other c-doc-comment-style))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2049 c-doc-comment-style)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2050 (list (nconc (apply 'nconc |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2051 (mapcar |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2052 (lambda (doc-style) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2053 (let ((sym (intern |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2054 (concat (symbol-name doc-style) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2055 "-font-lock-keywords")))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2056 (cond ((fboundp sym) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2057 (funcall sym)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2058 ((boundp sym) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2059 (append (eval sym) nil))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2060 (if (listp doc-keywords) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2061 doc-keywords |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2062 (list doc-keywords)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2063 base-list))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2064 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2065 ;; Kludge: If `c-font-lock-complex-decl-prepare' is on the list we |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2066 ;; move it first since the doc comment font lockers might add |
51829
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2067 ;; `c-type' text properties, so they have to be cleared before that. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2068 (when (memq 'c-font-lock-complex-decl-prepare list) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2069 (setq list (cons 'c-font-lock-complex-decl-prepare |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2070 (delq 'c-font-lock-complex-decl-prepare |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2071 (append list nil))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2072 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2073 list)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2074 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2075 (defun c-override-default-keywords (def-var) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2076 ;; This is used to override the value on a `*-font-lock-keywords' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2077 ;; variable only if it's nil or has the same value as one of the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2078 ;; `*-font-lock-keywords-*' variables. Older font-lock packages |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2079 ;; define a default value for `*-font-lock-keywords' which we want |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2080 ;; to override, but we should otoh avoid clobbering a user setting. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2081 ;; This heuristic for that isn't perfect, but I can't think of any |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2082 ;; better. /mast |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2083 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2084 ;; This function does not do any hidden buffer changes. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2085 (when (and (boundp def-var) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2086 (memq (symbol-value def-var) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2087 (cons nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2088 (mapcar |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2089 (lambda (suffix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2090 (let ((sym (intern (concat (symbol-name def-var) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2091 suffix)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2092 (and (boundp sym) (symbol-value sym)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2093 '("-1" "-2" "-3"))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2094 ;; The overriding is done by unbinding the variable so that the normal |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2095 ;; defvar will install its default value later on. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2096 (makunbound def-var))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2097 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2098 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2099 ;;; C. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2100 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2101 (c-override-default-keywords 'c-font-lock-keywords) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2102 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2103 (defconst c-font-lock-keywords-1 (c-lang-const c-matchers-1 c) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2104 "Minimal font locking for C mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2105 Fontifies only preprocessor directives (in addition to the syntactic |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2106 fontification of strings and comments).") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2107 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2108 (defconst c-font-lock-keywords-2 (c-lang-const c-matchers-2 c) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2109 "Fast normal font locking for C mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2110 In addition to `c-font-lock-keywords-1', this adds fontification of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2111 keywords, simple types, declarations that are easy to recognize, the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2112 user defined types on `c-font-lock-extra-types', and the doc comment |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2113 styles specified by `c-doc-comment-style'.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2114 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2115 (defconst c-font-lock-keywords-3 (c-lang-const c-matchers-3 c) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2116 "Accurate normal font locking for C mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2117 Like `c-font-lock-keywords-2' but detects declarations in a more |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2118 accurate way that works in most cases for arbitrary types without the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2119 need for `c-font-lock-extra-types'.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2120 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2121 (defvar c-font-lock-keywords c-font-lock-keywords-3 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2122 "Default expressions to highlight in C mode.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2123 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2124 (defun c-font-lock-keywords-2 () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2125 (c-compose-keywords-list c-font-lock-keywords-2)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2126 (defun c-font-lock-keywords-3 () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2127 (c-compose-keywords-list c-font-lock-keywords-3)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2128 (defun c-font-lock-keywords () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2129 (c-compose-keywords-list c-font-lock-keywords)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2130 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2131 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2132 ;;; C++. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2133 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2134 (defun c-font-lock-c++-new (limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2135 ;; Assuming point is after a "new" word, check that it isn't inside |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2136 ;; a string or comment, and if so try to fontify the type in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2137 ;; allocation expression. Nil is always returned. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2138 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2139 ;; As usual, C++ takes the prize in coming up with a hard to parse |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2140 ;; syntax. :P |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2141 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2142 (unless (c-skip-comments-and-strings limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2143 (save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2144 (catch 'false-alarm |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2145 ;; A "new" keyword is followed by one to three expressions, where |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2146 ;; the type is the middle one, and the only required part. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2147 (let (expr1-pos expr2-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2148 ;; Enable recording of identifier ranges in `c-forward-type' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2149 ;; etc for later fontification. Not using |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2150 ;; `c-fontify-types-and-refs' here since the ranges should |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2151 ;; be fontified selectively only when an allocation |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2152 ;; expression is successfully recognized. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2153 (c-record-type-identifiers t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2154 c-record-ref-identifiers |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2155 ;; The font-lock package in Emacs is known to clobber |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2156 ;; `parse-sexp-lookup-properties' (when it exists). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2157 (parse-sexp-lookup-properties |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2158 (cc-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2159 (boundp 'parse-sexp-lookup-properties)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2160 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2161 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2162 ;; The first placement arglist is always parenthesized, if it |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2163 ;; exists. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2164 (when (eq (char-after) ?\() |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2165 (setq expr1-pos (1+ (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2166 (condition-case nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2167 (c-forward-sexp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2168 (scan-error (throw 'false-alarm t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2169 (c-forward-syntactic-ws)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2170 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2171 ;; The second expression is either a type followed by some "*" or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2172 ;; "[...]" or similar, or a parenthesized type followed by a full |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2173 ;; identifierless declarator. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2174 (setq expr2-pos (1+ (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2175 (cond ((eq (char-after) ?\()) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2176 ((let ((c-promote-possible-types t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2177 (c-forward-type))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2178 (t (setq expr2-pos nil))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2179 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2180 (when expr1-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2181 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2182 ((not expr2-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2183 ;; No second expression, so the first has to be a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2184 ;; parenthesized type. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2185 (goto-char expr1-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2186 (let ((c-promote-possible-types t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2187 (c-forward-type))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2188 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2189 ((eq (char-before expr2-pos) ?\() |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2190 ;; Got two parenthesized expressions, so we have to look |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2191 ;; closer at them to decide which is the type. No need to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2192 ;; handle `c-record-ref-identifiers' since all references |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2193 ;; has already been handled by other fontification rules. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2194 (let (expr1-res expr2-res) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2195 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2196 (goto-char expr1-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2197 (when (setq expr1-res (c-forward-type)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2198 (unless (looking-at |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2199 (cc-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2200 (concat (c-lang-const c-symbol-start c++) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2201 "\\|[*:\)\[]"))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2202 ;; There's something after the would-be type that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2203 ;; can't be there, so this is a placement arglist. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2204 (setq expr1-res nil))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2205 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2206 (goto-char expr2-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2207 (when (setq expr2-res (c-forward-type)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2208 (unless (looking-at |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2209 (cc-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2210 (concat (c-lang-const c-symbol-start c++) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2211 "\\|[*:\)\[]"))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2212 ;; There's something after the would-be type that can't |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2213 ;; be there, so this is an initialization expression. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2214 (setq expr2-res nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2215 (when (and (c-go-up-list-forward) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2216 (progn (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2217 (eq (char-after) ?\())) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2218 ;; If there's a third initialization expression |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2219 ;; then the second one is the type, so demote the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2220 ;; first match. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2221 (setq expr1-res nil))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2222 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2223 ;; We fontify the most likely type, with a preference for |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2224 ;; the first argument since a placement arglist is more |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2225 ;; unusual than an initializer. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2226 (cond ((memq expr1-res '(t known prefix))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2227 ((memq expr2-res '(t known prefix))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2228 ((eq expr1-res 'found) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2229 (let ((c-promote-possible-types t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2230 (goto-char expr1-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2231 (c-forward-type))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2232 ((eq expr2-res 'found) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2233 (let ((c-promote-possible-types t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2234 (goto-char expr2-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2235 (c-forward-type))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2236 ((and (eq expr1-res 'maybe) (not expr2-res)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2237 (let ((c-promote-possible-types t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2238 (goto-char expr1-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2239 (c-forward-type))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2240 ((and (not expr1-res) (eq expr2-res 'maybe)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2241 (let ((c-promote-possible-types t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2242 (goto-char expr2-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2243 (c-forward-type))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2244 ;; If both type matches are 'maybe then we're |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2245 ;; too uncertain to promote either of them. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2246 ))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2247 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2248 ;; Fontify the type that now is recorded in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2249 ;; `c-record-type-identifiers', if any. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2250 (c-fontify-recorded-types-and-refs))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2251 nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2252 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2253 (c-override-default-keywords 'c++-font-lock-keywords) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2254 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2255 (defconst c++-font-lock-keywords-1 (c-lang-const c-matchers-1 c++) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2256 "Minimal font locking for C++ mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2257 Fontifies only preprocessor directives (in addition to the syntactic |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2258 fontification of strings and comments).") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2259 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2260 (defconst c++-font-lock-keywords-2 (c-lang-const c-matchers-2 c++) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2261 "Fast normal font locking for C++ mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2262 In addition to `c++-font-lock-keywords-1', this adds fontification of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2263 keywords, simple types, declarations that are easy to recognize, the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2264 user defined types on `c++-font-lock-extra-types', and the doc comment |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2265 styles specified by `c-doc-comment-style'.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2266 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2267 (defconst c++-font-lock-keywords-3 (c-lang-const c-matchers-3 c++) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2268 "Accurate normal font locking for C++ mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2269 Like `c++-font-lock-keywords-2' but detects declarations in a more |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2270 accurate way that works in most cases for arbitrary types without the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2271 need for `c++-font-lock-extra-types'.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2272 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2273 (defvar c++-font-lock-keywords c++-font-lock-keywords-3 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2274 "Default expressions to highlight in C++ mode.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2275 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2276 (defun c++-font-lock-keywords-2 () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2277 (c-compose-keywords-list c++-font-lock-keywords-2)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2278 (defun c++-font-lock-keywords-3 () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2279 (c-compose-keywords-list c++-font-lock-keywords-3)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2280 (defun c++-font-lock-keywords () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2281 (c-compose-keywords-list c++-font-lock-keywords)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2282 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2283 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2284 ;;; Objective-C. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2285 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2286 (defun c-font-lock-objc-iip-decl () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2287 ;; Assuming the point is after an "@interface", "@implementation", |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2288 ;; "@protocol" declaration, fontify all the types in the directive. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2289 ;; Return t if the directive was fully recognized. Point will then |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2290 ;; be at the end of it. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2291 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2292 (c-fontify-types-and-refs |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2293 (start-char |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2294 (c-promote-possible-types t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2295 ;; Turn off recognition of angle bracket arglists while parsing |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2296 ;; types here since the protocol reference list might then be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2297 ;; considered part of the preceding name or superclass-name. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2298 c-recognize-<>-arglists) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2299 (catch 'break |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2300 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2301 ;; Handle the name of the class itself. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2302 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2303 (unless (c-forward-type) (throw 'break nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2304 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2305 ;; Look for ": superclass-name" or "( category-name )". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2306 (when (looking-at "[:\(]") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2307 (setq start-char (char-after)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2308 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2309 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2310 (unless (c-forward-type) (throw 'break nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2311 (when (eq start-char ?\() |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2312 (unless (eq (char-after) ?\)) (throw 'break nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2313 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2314 (c-forward-syntactic-ws))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2315 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2316 ;; Look for a protocol reference list. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2317 (when (if (eq (char-after) ?<) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2318 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2319 (setq c-recognize-<>-arglists t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2320 (c-forward-<>-arglist t t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2321 t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2322 (c-put-char-property (1- (point)) 'c-type 'c-decl-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2323 t)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2324 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2325 (defun c-font-lock-objc-method () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2326 ;; Assuming the point is after the + or - that starts an Objective-C |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2327 ;; method declaration, fontify it. This must be done before normal |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2328 ;; casts, declarations and labels are fontified since they will get |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2329 ;; false matches in these things. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2330 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2331 (c-fontify-types-and-refs |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2332 ((first t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2333 (c-promote-possible-types t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2334 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2335 (while (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2336 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2337 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2338 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2339 ;; An optional method type. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2340 (if (eq (char-after) ?\() |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2341 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2342 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2343 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2344 (c-forward-type) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2345 (prog1 (c-go-up-list-forward) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2346 (c-forward-syntactic-ws))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2347 t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2348 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2349 ;; The name. The first time it's the first part of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2350 ;; the function name, the rest of the time it's an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2351 ;; argument name. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2352 (looking-at c-symbol-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2353 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2354 (goto-char (match-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2355 (c-put-font-lock-face (match-beginning 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2356 (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2357 (if first |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2358 'font-lock-function-name-face |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2359 'font-lock-variable-name-face)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2360 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2361 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2362 ;; Another optional part of the function name. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2363 (when (looking-at c-symbol-key) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2364 (goto-char (match-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2365 (c-put-font-lock-face (match-beginning 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2366 (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2367 'font-lock-function-name-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2368 (c-forward-syntactic-ws)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2369 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2370 ;; There's another argument if a colon follows. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2371 (eq (char-after) ?:))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2372 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2373 (setq first nil)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2374 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2375 (defun c-font-lock-objc-methods (limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2376 ;; Fontify method declarations in Objective-C. Nil is always |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2377 ;; returned. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2378 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2379 (let (;; The font-lock package in Emacs is known to clobber |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2380 ;; `parse-sexp-lookup-properties' (when it exists). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2381 (parse-sexp-lookup-properties |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2382 (cc-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2383 (boundp 'parse-sexp-lookup-properties)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2384 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2385 (c-find-decl-spots |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2386 limit |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2387 "[-+]" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2388 nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2389 (lambda (match-pos inside-macro) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2390 (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2391 (c-font-lock-objc-method)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2392 nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2393 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2394 (c-override-default-keywords 'objc-font-lock-keywords) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2395 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2396 (defconst objc-font-lock-keywords-1 (c-lang-const c-matchers-1 objc) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2397 "Minimal font locking for Objective-C mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2398 Fontifies only compiler directives (in addition to the syntactic |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2399 fontification of strings and comments).") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2400 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2401 (defconst objc-font-lock-keywords-2 (c-lang-const c-matchers-2 objc) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2402 "Fast normal font locking for Objective-C mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2403 In addition to `objc-font-lock-keywords-1', this adds fontification of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2404 keywords, simple types, declarations that are easy to recognize, the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2405 user defined types on `objc-font-lock-extra-types', and the doc |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2406 comment styles specified by `c-doc-comment-style'.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2407 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2408 (defconst objc-font-lock-keywords-3 (c-lang-const c-matchers-3 objc) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2409 "Accurate normal font locking for Objective-C mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2410 Like `objc-font-lock-keywords-2' but detects declarations in a more |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2411 accurate way that works in most cases for arbitrary types without the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2412 need for `objc-font-lock-extra-types'.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2413 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2414 (defvar objc-font-lock-keywords objc-font-lock-keywords-3 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2415 "Default expressions to highlight in Objective-C mode.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2416 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2417 (defun objc-font-lock-keywords-2 () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2418 (c-compose-keywords-list objc-font-lock-keywords-2)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2419 (defun objc-font-lock-keywords-3 () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2420 (c-compose-keywords-list objc-font-lock-keywords-3)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2421 (defun objc-font-lock-keywords () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2422 (c-compose-keywords-list objc-font-lock-keywords)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2423 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2424 ;; Kludge to override the default value that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2425 ;; `objc-font-lock-extra-types' might have gotten from the font-lock |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2426 ;; package. The value replaced here isn't relevant now anyway since |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2427 ;; those types are builtin and therefore listed directly in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2428 ;; `c-primitive-type-kwds'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2429 (when (equal (sort (append objc-font-lock-extra-types nil) 'string-lessp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2430 '("BOOL" "Class" "IMP" "SEL")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2431 (setq objc-font-lock-extra-types |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2432 (cc-eval-when-compile (list (concat "[" c-upper "]\\sw*"))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2433 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2434 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2435 ;;; Java. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2436 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2437 (c-override-default-keywords 'java-font-lock-keywords) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2438 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2439 (defconst java-font-lock-keywords-1 (c-lang-const c-matchers-1 java) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2440 "Minimal font locking for Java mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2441 Fontifies nothing except the syntactic fontification of strings and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2442 comments.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2443 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2444 (defconst java-font-lock-keywords-2 (c-lang-const c-matchers-2 java) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2445 "Fast normal font locking for Java mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2446 In addition to `java-font-lock-keywords-1', this adds fontification of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2447 keywords, simple types, declarations that are easy to recognize, the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2448 user defined types on `java-font-lock-extra-types', and the doc |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2449 comment styles specified by `c-doc-comment-style'.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2450 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2451 (defconst java-font-lock-keywords-3 (c-lang-const c-matchers-3 java) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2452 "Accurate normal font locking for Java mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2453 Like `java-font-lock-keywords-2' but detects declarations in a more |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2454 accurate way that works in most cases for arbitrary types without the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2455 need for `java-font-lock-extra-types'.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2456 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2457 (defvar java-font-lock-keywords java-font-lock-keywords-3 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2458 "Default expressions to highlight in Java mode.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2459 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2460 (defun java-font-lock-keywords-2 () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2461 (c-compose-keywords-list java-font-lock-keywords-2)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2462 (defun java-font-lock-keywords-3 () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2463 (c-compose-keywords-list java-font-lock-keywords-3)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2464 (defun java-font-lock-keywords () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2465 (c-compose-keywords-list java-font-lock-keywords)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2466 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2467 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2468 ;;; CORBA IDL. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2469 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2470 (c-override-default-keywords 'idl-font-lock-keywords) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2471 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2472 (defconst idl-font-lock-keywords-1 (c-lang-const c-matchers-1 idl) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2473 "Minimal font locking for CORBA IDL mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2474 Fontifies nothing except the syntactic fontification of strings and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2475 comments.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2476 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2477 (defconst idl-font-lock-keywords-2 (c-lang-const c-matchers-2 idl) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2478 "Fast normal font locking for CORBA IDL mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2479 In addition to `idl-font-lock-keywords-1', this adds fontification of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2480 keywords, simple types, declarations that are easy to recognize, the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2481 user defined types on `idl-font-lock-extra-types', and the doc comment |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2482 styles specified by `c-doc-comment-style'.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2483 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2484 (defconst idl-font-lock-keywords-3 (c-lang-const c-matchers-3 idl) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2485 "Accurate normal font locking for CORBA IDL mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2486 Like `idl-font-lock-keywords-2' but detects declarations in a more |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2487 accurate way that works in most cases for arbitrary types without the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2488 need for `idl-font-lock-extra-types'.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2489 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2490 (defvar idl-font-lock-keywords idl-font-lock-keywords-3 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2491 "Default expressions to highlight in CORBA IDL mode.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2492 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2493 (defun idl-font-lock-keywords-2 () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2494 (c-compose-keywords-list idl-font-lock-keywords-2)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2495 (defun idl-font-lock-keywords-3 () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2496 (c-compose-keywords-list idl-font-lock-keywords-3)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2497 (defun idl-font-lock-keywords () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2498 (c-compose-keywords-list idl-font-lock-keywords)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2499 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2500 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2501 ;;; Pike. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2502 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2503 (c-override-default-keywords 'pike-font-lock-keywords) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2504 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2505 (defconst pike-font-lock-keywords-1 (c-lang-const c-matchers-1 pike) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2506 "Minimal font locking for Pike mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2507 Fontifies only preprocessor directives (in addition to the syntactic |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2508 fontification of strings and comments).") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2509 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2510 (defconst pike-font-lock-keywords-2 (c-lang-const c-matchers-2 pike) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2511 "Fast normal font locking for Pike mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2512 In addition to `pike-font-lock-keywords-1', this adds fontification of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2513 keywords, simple types, declarations that are easy to recognize, the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2514 user defined types on `pike-font-lock-extra-types', and the doc |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2515 comment styles specified by `c-doc-comment-style'.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2516 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2517 (defconst pike-font-lock-keywords-3 (c-lang-const c-matchers-3 pike) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2518 "Accurate normal font locking for Pike mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2519 Like `pike-font-lock-keywords-2' but detects declarations in a more |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2520 accurate way that works in most cases for arbitrary types without the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2521 need for `pike-font-lock-extra-types'.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2522 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2523 (defvar pike-font-lock-keywords pike-font-lock-keywords-3 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2524 "Default expressions to highlight in Pike mode.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2525 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2526 (defun pike-font-lock-keywords-2 () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2527 (c-compose-keywords-list pike-font-lock-keywords-2)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2528 (defun pike-font-lock-keywords-3 () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2529 (c-compose-keywords-list pike-font-lock-keywords-3)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2530 (defun pike-font-lock-keywords () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2531 (c-compose-keywords-list pike-font-lock-keywords)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2532 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2533 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2534 ;;; Doc comments. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2535 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2536 (defun c-font-lock-doc-comments (prefix limit keywords) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2537 ;; Fontify the comments between the point and LIMIT whose start |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2538 ;; matches PREFIX with `c-doc-face-name'. Assumes comments have been |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2539 ;; fontified with `font-lock-comment-face' already. nil is always |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2540 ;; returned. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2541 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2542 ;; After the fontification of a matching comment, fontification |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2543 ;; according to KEYWORDS is applied inside it. It's a list like |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2544 ;; `font-lock-keywords' except that anchored matches and eval |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2545 ;; clauses aren't supported and that some abbreviated forms can't be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2546 ;; used. The buffer is narrowed to the comment while KEYWORDS is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2547 ;; applied; leading comment starters are included but trailing |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2548 ;; comment enders for block comment are not. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2549 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2550 ;; Note that faces added through KEYWORDS should never replace the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2551 ;; existing `c-doc-face-name' face since the existence of that face |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2552 ;; is used as a flag in other code to skip comments. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2553 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2554 (let (comment-beg region-beg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2555 (if (eq (get-text-property (point) 'face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2556 'font-lock-comment-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2557 ;; Handle the case when the fontified region starts inside a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2558 ;; comment. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2559 (let ((range (c-literal-limits))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2560 (setq region-beg (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2561 (when range |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2562 (goto-char (car range))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2563 (when (looking-at prefix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2564 (setq comment-beg (point))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2565 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2566 (while (or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2567 comment-beg |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2568 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2569 ;; Search for the prefix until a match is found at the start |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2570 ;; of a comment. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2571 (while (when (re-search-forward prefix limit t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2572 (setq comment-beg (match-beginning 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2573 (or (not (c-got-face-at comment-beg |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2574 c-literal-faces)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2575 (and (/= comment-beg (point-min)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2576 (c-got-face-at (1- comment-beg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2577 c-literal-faces)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2578 (setq comment-beg nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2579 (setq region-beg comment-beg)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2580 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2581 (if (eq (elt (parse-partial-sexp comment-beg (+ comment-beg 2)) 7) t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2582 ;; Collect a sequence of doc style line comments. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2583 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2584 (goto-char comment-beg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2585 (while (and (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2586 (c-forward-single-comment) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2587 (skip-syntax-forward " ") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2588 (< (point) limit)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2589 (looking-at prefix)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2590 (goto-char comment-beg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2591 (c-forward-single-comment)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2592 (if (> (point) limit) (goto-char limit)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2593 (setq comment-beg nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2594 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2595 (let ((region-end (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2596 (keylist keywords) keyword matcher highlights) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2597 (c-put-font-lock-face region-beg region-end c-doc-face-name) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2598 (save-restriction |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2599 ;; Narrow to the doc comment. Among other things, this |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2600 ;; helps by making "^" match at the start of the comment. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2601 ;; Do not include a trailing block comment ender, though. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2602 (and (> region-end (1+ region-beg)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2603 (progn (goto-char region-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2604 (backward-char 2) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2605 (looking-at "\\*/")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2606 (setq region-end (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2607 (narrow-to-region region-beg region-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2608 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2609 (while keylist |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2610 (setq keyword (car keylist) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2611 keylist (cdr keylist) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2612 matcher (car keyword)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2613 (goto-char region-beg) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2614 (while (if (stringp matcher) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2615 (re-search-forward matcher region-end t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2616 (funcall matcher region-end)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2617 (setq highlights (cdr keyword)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2618 (if (consp (car highlights)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2619 (while highlights |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2620 (font-lock-apply-highlight (car highlights)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2621 (setq highlights (cdr highlights))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2622 (font-lock-apply-highlight highlights)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2623 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2624 (goto-char region-end))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2625 nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2626 (put 'c-font-lock-doc-comments 'lisp-indent-function 2) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2627 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2628 (defun c-find-invalid-doc-markup (regexp limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2629 ;; Used to fontify invalid markup in doc comments after the correct |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2630 ;; ones have been fontified: Find the first occurence of REGEXP |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2631 ;; between the point and LIMIT that only is fontified with |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2632 ;; `c-doc-face-name'. If a match is found then submatch 0 surrounds |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2633 ;; the first char and t is returned, otherwise nil is returned. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2634 (let (start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2635 (while (if (re-search-forward regexp limit t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2636 (not (eq (get-text-property |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2637 (setq start (match-beginning 0)) 'face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2638 c-doc-face-name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2639 (setq start nil))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2640 (when start |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2641 (store-match-data (list (copy-marker start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2642 (copy-marker (1+ start)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2643 t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2644 |
51829
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2645 (defconst javadoc-font-lock-doc-comments |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2646 `(("{@[a-z]+[^}\n\r]*}" ; "{@foo ...}" markup. |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2647 0 ,c-doc-markup-face-name prepend nil) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2648 ("^\\(/\\*\\)?[ \t*]*\\(@[a-z]+\\)" ; "@foo ..." markup. |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2649 2 ,c-doc-markup-face-name prepend nil) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2650 (,(concat "</?\\sw" ; HTML tags. |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2651 "\\(" |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2652 (concat "\\sw\\|\\s \\|[=\n\r*.:]\\|" |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2653 "\"[^\"]*\"\\|'[^']*'") |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2654 "\\)*>") |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2655 0 ,c-doc-markup-face-name prepend nil) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2656 ("&\\(\\sw\\|[.:]\\)+;" ; HTML entities. |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2657 0 ,c-doc-markup-face-name prepend nil) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2658 ;; Fontify remaining markup characters as invalid. Note |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2659 ;; that the Javadoc spec is hazy about when "@" is |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2660 ;; allowed in non-markup use. |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2661 (,(lambda (limit) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2662 (c-find-invalid-doc-markup "[<>&]\\|{@" limit)) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2663 0 ,c-invalid-face-name prepend nil))) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2664 |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2665 (defconst javadoc-font-lock-keywords |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2666 `((,(lambda (limit) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2667 (c-font-lock-doc-comments "/\\*\\*" limit |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2668 javadoc-font-lock-doc-comments))))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2669 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2670 (defconst autodoc-decl-keywords |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2671 ;; Adorned regexp matching the keywords that introduce declarations |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2672 ;; in Pike Autodoc. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2673 (cc-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2674 (c-make-keywords-re t '("@decl" "@elem" "@index" "@member") 'pike-mode))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2675 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2676 (defconst autodoc-decl-type-keywords |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2677 ;; Adorned regexp matching the keywords that are followed by a type. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2678 (cc-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2679 (c-make-keywords-re t '("@elem" "@member") 'pike-mode))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2680 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2681 (defun autodoc-font-lock-line-markup (limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2682 ;; Fontify all line oriented keywords between the point and LIMIT. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2683 ;; Nil is always returned. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2684 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2685 (let ((line-re (concat "^\\(\\(/\\*!\\|\\s *\\(" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2686 c-current-comment-prefix |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2687 "\\)\\)\\s *\\)@[A-Za-z_-]+\\(\\s \\|$\\)")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2688 (markup-faces (list c-doc-markup-face-name c-doc-face-name))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2689 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2690 (while (re-search-forward line-re limit t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2691 (goto-char (match-end 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2692 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2693 (if (looking-at autodoc-decl-keywords) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2694 (let* ((kwd-pos (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2695 (start (match-end 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2696 (pos start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2697 end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2698 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2699 (c-put-font-lock-face (point) pos markup-faces) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2700 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2701 ;; Put a declaration end mark at the markup keyword and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2702 ;; remove the faces from the rest of the line so that it |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2703 ;; gets refontified as a declaration later on by |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2704 ;; `c-font-lock-declarations'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2705 (c-put-char-property (1- pos) 'c-type 'c-decl-end) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2706 (goto-char pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2707 (while (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2708 (end-of-line) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2709 (setq end (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2710 (and (eq (char-before) ?@) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2711 (not (eobp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2712 (progn (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2713 (skip-chars-forward " \t") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2714 (looking-at c-current-comment-prefix)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2715 (goto-char (match-end 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2716 (c-remove-font-lock-face pos (1- end)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2717 (c-put-font-lock-face (1- end) end markup-faces) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2718 (setq pos (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2719 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2720 ;; Include the final newline in the removed area. This |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2721 ;; has no visual effect but it avoids some tricky special |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2722 ;; cases in the testsuite wrt the differences in string |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2723 ;; fontification in Emacs vs XEmacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2724 (c-remove-font-lock-face pos (min (1+ (point)) (point-max))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2725 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2726 ;; Must handle string literals explicitly inside the declaration. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2727 (goto-char start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2728 (while (re-search-forward |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2729 "\"\\([^\\\"]\\|\\\\.\\)*\"\\|'\\([^\\']\\|\\\\.\\)*'" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2730 end 'move) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2731 (c-put-font-lock-string-face (match-beginning 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2732 (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2733 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2734 ;; Fontify types after keywords that always are followed |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2735 ;; by them. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2736 (goto-char kwd-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2737 (when (looking-at autodoc-decl-type-keywords) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2738 (c-fontify-types-and-refs ((c-promote-possible-types t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2739 (goto-char start) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2740 (c-forward-syntactic-ws) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2741 (c-forward-type)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2742 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2743 ;; Mark each whole line as markup, as long as the logical line |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2744 ;; continues. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2745 (while (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2746 (c-put-font-lock-face (point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2747 (progn (end-of-line) (point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2748 markup-faces) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2749 (and (eq (char-before) ?@) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2750 (not (eobp)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2751 (progn (forward-char) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2752 (skip-chars-forward " \t") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2753 (looking-at c-current-comment-prefix)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2754 (goto-char (match-end 0)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2755 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2756 nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2757 |
51829
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2758 (defconst autodoc-font-lock-doc-comments |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2759 `(("@\\(\\w+{\\|\\[\\([^\]@\n\r]\\|@@\\)*\\]\\|[@}]\\|$\\)" |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2760 ;; In-text markup. |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2761 0 ,c-doc-markup-face-name prepend nil) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2762 (autodoc-font-lock-line-markup) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2763 ;; Fontify remaining markup characters as invalid. |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2764 (,(lambda (limit) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2765 (c-find-invalid-doc-markup "@" limit)) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2766 0 ,c-invalid-face-name prepend nil) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2767 )) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2768 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2769 (defun autodoc-font-lock-keywords () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2770 ;; Note that we depend on that `c-current-comment-prefix' has got |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2771 ;; its proper value here. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2772 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2773 ;; The `c-type' text property with `c-decl-end' is used to mark the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2774 ;; end of the `autodoc-decl-keywords' occurrences to fontify the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2775 ;; following declarations. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2776 (setq c-type-decl-end-used t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2777 |
51829
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2778 `((,(lambda (limit) |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2779 (c-font-lock-doc-comments "/[*/]!" limit |
d508ffa43505
2003-07-08 Martin Stjernholm <bug-cc-mode@gnu.org>
Martin Stjernholm <mast@lysator.liu.se>
parents:
51714
diff
changeset
|
2780 autodoc-font-lock-doc-comments))))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2781 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2782 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2783 ;; AWK. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2784 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2785 ;; Awk regexps written with help from Peter Galbraith |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2786 ;; <galbraith@mixing.qc.dfo.ca>. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2787 ;; Take GNU Emacs's 'words out of the following regexp-opts. They dont work |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2788 ;; in Xemacs 21.4.4. acm 2002/9/19. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2789 (eval-after-load "cc-awk" ; Evaluate while loading cc-fonts |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2790 `(defconst awk-font-lock-keywords ; Evaluate after loading cc-awk |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2791 ',(eval-when-compile ; Evaluate while compiling cc-fonts |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2792 (list |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2793 ;; Function names. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2794 '("^[ \t]*\\(func\\(tion\\)?\\)\\>[ \t]*\\(\\sw+\\)?" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2795 (1 font-lock-keyword-face) (3 font-lock-function-name-face nil t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2796 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2797 ;; Variable names. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2798 (cons |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2799 (concat "\\<" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2800 (c-regexp-opt |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2801 '("ARGC" "ARGIND" "ARGV" "BINMODE" "CONVFMT" "ENVIRON" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2802 "ERRNO" "FIELDWIDTHS" "FILENAME" "FNR" "FS" "IGNORECASE" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2803 "LINT" "NF" "NR" "OFMT" "OFS" "ORS" "PROCINFO" "RLENGTH" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2804 "RS" "RSTART" "RT" "SUBSEP" "TEXTDOMAIN") t) "\\>") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2805 'font-lock-variable-name-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2806 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2807 ;; Special file names. (acm, 2002/7/22) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2808 ;; The following regexp was created by first evaluating this in GNU Emacs 21.1: |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2809 ;; (c-regexp-opt '("/dev/stdin" "/dev/stdout" "/dev/stderr" "/dev/fd/n" "/dev/pid" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2810 ;; "/dev/ppid" "/dev/pgrpid" "/dev/user") 'words) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2811 ;; , removing the "?:" from each "\\(?:" (for backward compatibility with older Emacsen) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2812 ;; , replacing the "n" in "dev/fd/n" with "[0-9]+" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2813 ;; , removing the unwanted \\< at the beginning, and finally filling out the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2814 ;; regexp so that a " must come before, and either a " or heuristic stuff after. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2815 ;; The surrounding quotes are fontified along with the filename, since, semantically, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2816 ;; they are an indivisible unit. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2817 '("\\(\"/dev/\\(fd/[0-9]+\\|p\\(\\(\\(gr\\)?p\\)?id\\)\\|\ |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2818 std\\(err\\|in\\|out\\)\\|user\\)\\)\\>\ |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2819 \\(\\(\"\\)\\|\\([^\"/\n\r][^\"\n\r]*\\)?$\\)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2820 (1 font-lock-variable-name-face t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2821 (8 font-lock-variable-name-face t t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2822 ;; Do the same (almost) with |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2823 ;; (c-regexp-opt '("/inet/tcp/lport/rhost/rport" "/inet/udp/lport/rhost/rport" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2824 ;; "/inet/raw/lport/rhost/rport") 'words) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2825 ;; This cannot be combined with the above pattern, because the match number |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2826 ;; for the (optional) closing \" would then exceed 9. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2827 '("\\(\"/inet/\\(\\(raw\\|\\(tc\\|ud\\)p\\)/lport/rhost/rport\\)\\)\\>\ |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2828 \\(\\(\"\\)\\|\\([^\"/\n\r][^\"\n\r]*\\)?$\\)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2829 (1 font-lock-variable-name-face t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2830 (6 font-lock-variable-name-face t t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2831 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2832 ;; Keywords. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2833 (concat "\\<" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2834 (c-regexp-opt |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2835 '("BEGIN" "END" "break" "continue" "delete" "do" "else" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2836 "exit" "for" "getline" "if" "in" "next" "nextfile" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2837 "return" "while") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2838 t) "\\>") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2839 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2840 ;; Builtins. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2841 `(eval . (list |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2842 ,(concat |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2843 "\\<" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2844 (c-regexp-opt |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2845 '("adump" "and" "asort" "atan2" "bindtextdomain" "close" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2846 "compl" "cos" "dcgettext" "exp" "extension" "fflush" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2847 "gensub" "gsub" "index" "int" "length" "log" "lshift" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2848 "match" "mktime" "or" "print" "printf" "rand" "rshift" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2849 "sin" "split" "sprintf" "sqrt" "srand" "stopme" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2850 "strftime" "strtonum" "sub" "substr" "system" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2851 "systime" "tolower" "toupper" "xor") t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2852 "\\>") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2853 0 c-preprocessor-face-name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2854 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2855 ;; gawk debugging keywords. (acm, 2002/7/21) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2856 ;; (Removed, 2003/6/6. These functions are now fontified as built-ins) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2857 ;; (list (concat "\\<" (c-regexp-opt '("adump" "stopme") t) "\\>") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2858 ;; 0 'font-lock-warning-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2859 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2860 ;; User defined functions with an apparent spurious space before the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2861 ;; opening parenthesis. acm, 2002/5/30. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2862 `(,(concat "\\(\\w\\|_\\)" c-awk-escaped-nls* "[ \t]" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2863 c-awk-escaped-nls*-with-space* "(") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2864 (0 'font-lock-warning-face)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2865 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2866 ;; Space after \ in what looks like an escaped newline. 2002/5/31 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2867 '("\\\\[ \t]+$" 0 font-lock-warning-face t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2868 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2869 ;; Unbalanced string (") or regexp (/) delimiters. 2002/02/16. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2870 '("\\s|" 0 font-lock-warning-face t nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2871 ;; gawk 3.1 localizable strings ( _"translate me!"). 2002/5/21 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2872 '("\\(_\\)\\s|" 1 font-lock-warning-face) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2873 '("\\(_\\)\\s\"" 1 font-lock-string-face) ; FIXME! not for XEmacs. 2002/10/6 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2874 )) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2875 "Default expressions to highlight in AWK mode.")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2876 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2877 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2878 (cc-provide 'cc-fonts) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2879 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
diff
changeset
|
2880 ;;; cc-fonts.el ends here |