Mercurial > emacs
annotate lisp/progmodes/cc-defs.el @ 90058:48f163b71dbf
(char-displayable-p): Check :charset-list property of CODING.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Thu, 09 Dec 2004 12:37:05 +0000 |
parents | d8411455de48 |
children | 5b029ff3b08d |
rev | line source |
---|---|
21112
b113342cb7ad
(c-emacs-features): Var moved to cc-vars.el.
Richard M. Stallman <rms@gnu.org>
parents:
20913
diff
changeset
|
1 ;;; cc-defs.el --- compile time definitions for CC Mode |
18720 | 2 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
3 ;; Copyright (C) 1985,1987,1992-2003 Free Software Foundation, Inc. |
18720 | 4 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
5 ;; Authors: 1998- Martin Stjernholm |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
6 ;; 1992-1999 Barry A. Warsaw |
18720 | 7 ;; 1987 Dave Detlefs and Stewart Clamen |
8 ;; 1985 Richard M. Stallman | |
24282 | 9 ;; Maintainer: bug-cc-mode@gnu.org |
18720 | 10 ;; Created: 22-Apr-1997 (split from cc-mode.el) |
20141 | 11 ;; Version: See cc-mode.el |
18720 | 12 ;; Keywords: c languages oop |
13 | |
14 ;; This file is part of GNU Emacs. | |
15 | |
16 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
17 ;; it under the terms of the GNU General Public License as published by | |
18 ;; the Free Software Foundation; either version 2, or (at your option) | |
19 ;; any later version. | |
20 | |
21 ;; GNU Emacs is distributed in the hope that it will be useful, | |
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
24 ;; GNU General Public License for more details. | |
25 | |
26 ;; You should have received a copy of the GNU General Public License | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
27 ;; along with GNU Emacs; see the file COPYING. If not, write to |
36920 | 28 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18720 | 29 ;; Boston, MA 02111-1307, USA. |
30 | |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
31 ;;; Commentary: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
32 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
33 ;; This file contains macros, defsubsts, and various other things that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
34 ;; must be loaded early both during compilation and at runtime. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
35 |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
36 ;;; Code: |
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
37 |
36920 | 38 (eval-when-compile |
39 (let ((load-path | |
40 (if (and (boundp 'byte-compile-dest-file) | |
41 (stringp byte-compile-dest-file)) | |
42 (cons (file-name-directory byte-compile-dest-file) load-path) | |
43 load-path))) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
44 (load "cc-bytecomp" nil t))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
45 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
46 ;; `require' in XEmacs doesn't have the third NOERROR argument. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
47 (condition-case nil (require 'regexp-opt) (file-error nil)) |
24282 | 48 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
49 ;; Silence the compiler. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
50 (cc-bytecomp-defvar c-enable-xemacs-performance-kludge-p) ; In cc-vars.el |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
51 (cc-bytecomp-defun buffer-syntactic-context-depth) ; XEmacs |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
52 (cc-bytecomp-defun region-active-p) ; XEmacs |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
53 (cc-bytecomp-defvar zmacs-region-stays) ; XEmacs |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
54 (cc-bytecomp-defvar zmacs-regions) ; XEmacs |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
55 (cc-bytecomp-defvar mark-active) ; Emacs |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
56 (cc-bytecomp-defvar deactivate-mark) ; Emacs |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
57 (cc-bytecomp-defvar inhibit-point-motion-hooks) ; Emacs |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
58 (cc-bytecomp-defvar parse-sexp-lookup-properties) ; Emacs 20+ |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
59 (cc-bytecomp-defvar text-property-default-nonsticky) ; Emacs 21 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
60 (cc-bytecomp-defvar lookup-syntax-properties) ; XEmacs 21 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
61 (cc-bytecomp-defun string-to-syntax) ; Emacs 21 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
62 (cc-bytecomp-defun regexp-opt-depth) ; (X)Emacs 20+ |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
63 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
64 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
65 ;; cc-fix.el contains compatibility macros that should be used if |
36920 | 66 ;; needed. |
67 (eval-and-compile | |
68 (if (or (not (fboundp 'functionp)) | |
69 (not (condition-case nil | |
70 (progn (eval '(char-before)) t) | |
71 (error nil))) | |
72 (not (condition-case nil | |
73 (progn (eval '(char-after)) t) | |
74 (error nil))) | |
75 (not (fboundp 'when)) | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
76 (not (fboundp 'unless)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
77 (not (fboundp 'regexp-opt)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
78 (not (cc-bytecomp-fboundp 'regexp-opt-depth)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
79 (/= (regexp-opt-depth "\\(\\(\\)\\)") 2)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
80 (cc-load "cc-fix") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
81 (defalias 'c-regexp-opt 'regexp-opt) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
82 (defalias 'c-regexp-opt-depth 'regexp-opt-depth))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
83 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
84 (eval-after-load "font-lock" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
85 '(if (and (not (featurep 'cc-fix)) ; only load the file once. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
86 (let (font-lock-keywords) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
87 (font-lock-compile-keywords '("\\<\\>")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
88 font-lock-keywords)) ; did the previous call foul this up? |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
89 (load "cc-fix"))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
90 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
91 ;; The above takes care of the delayed loading, but this is necessary |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
92 ;; to ensure correct byte compilation. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
93 (eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
94 (if (and (not (featurep 'cc-fix)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
95 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
96 (require 'font-lock) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
97 (let (font-lock-keywords) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
98 (font-lock-compile-keywords '("\\<\\>")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
99 font-lock-keywords))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
100 (cc-load "cc-fix"))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
101 |
53610
67b35df74057
Do not require cl at run time.
Luc Teirlinck <teirllm@auburn.edu>
parents:
53073
diff
changeset
|
102 (eval-when-compile (require 'cl)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
103 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
104 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
105 ;;; Variables also used at compile time. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
106 |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
107 (defconst c-version "5.30.9" |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
108 "CC Mode version number.") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
109 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
110 (defconst c-version-sym (intern c-version)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
111 ;; A little more compact and faster in comparisons. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
112 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
113 (defvar c-buffer-is-cc-mode nil |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
114 "Non-nil for all buffers with a major mode derived from CC Mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
115 Otherwise, this variable is nil. I.e. this variable is non-nil for |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
116 `c-mode', `c++-mode', `objc-mode', `java-mode', `idl-mode', |
52610
ab5832ac1f83
Bumped patch release number. Minor docstring update.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
117 `pike-mode', `awk-mode', and any other non-CC Mode mode that calls |
ab5832ac1f83
Bumped patch release number. Minor docstring update.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
118 `c-initialize-cc-mode'. The value is the mode symbol itself |
ab5832ac1f83
Bumped patch release number. Minor docstring update.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
119 \(i.e. `c-mode' etc) of the original CC Mode mode, or just t if it's |
ab5832ac1f83
Bumped patch release number. Minor docstring update.
Martin Stjernholm <mast@lysator.liu.se>
parents:
52401
diff
changeset
|
120 not known.") |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
121 (make-variable-buffer-local 'c-buffer-is-cc-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
122 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
123 ;; Have to make `c-buffer-is-cc-mode' permanently local so that it |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
124 ;; survives the initialization of the derived mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
125 (put 'c-buffer-is-cc-mode 'permanent-local t) |
36920 | 126 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
127 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
128 ;; The following is used below during compilation. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
129 (eval-and-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
130 (defvar c-inside-eval-when-compile nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
131 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
132 (defmacro cc-eval-when-compile (&rest body) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
133 "Like `progn', but evaluates the body at compile time. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
134 The result of the body appears to the compiler as a quoted constant. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
135 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
136 This variant works around bugs in `eval-when-compile' in various |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
137 \(X)Emacs versions. See cc-defs.el for details." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
138 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
139 (if c-inside-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
140 ;; XEmacs 21.4.6 has a bug in `eval-when-compile' in that it |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
141 ;; evaluates its body at macro expansion time if it's nested |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
142 ;; inside another `eval-when-compile'. So we use a dynamically |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
143 ;; bound variable to avoid nesting them. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
144 `(progn ,@body) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
145 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
146 `(eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
147 ;; In all (X)Emacsen so far, `eval-when-compile' byte compiles |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
148 ;; its contents before evaluating it. That can cause forms to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
149 ;; be compiled in situations they aren't intended to be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
150 ;; compiled. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
151 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
152 ;; Example: It's not possible to defsubst a primitive, e.g. the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
153 ;; following will produce an error (in any emacs flavor), since |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
154 ;; `nthcdr' is a primitive function that's handled specially by |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
155 ;; the byte compiler and thus can't be redefined: |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
156 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
157 ;; (defsubst nthcdr (val) val) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
158 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
159 ;; `defsubst', like `defmacro', needs to be evaluated at |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
160 ;; compile time, so this will produce an error during byte |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
161 ;; compilation. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
162 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
163 ;; CC Mode occasionally needs to do things like this for |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
164 ;; cross-emacs compatibility. It therefore uses the following |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
165 ;; to conditionally do a `defsubst': |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
166 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
167 ;; (eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
168 ;; (if (not (fboundp 'foo)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
169 ;; (defsubst foo ...))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
170 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
171 ;; But `eval-when-compile' byte compiles its contents and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
172 ;; _then_ evaluates it (in all current emacs versions, up to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
173 ;; and including Emacs 20.6 and XEmacs 21.1 as of this |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
174 ;; writing). So this will still produce an error, since the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
175 ;; byte compiler will get to the defsubst anyway. That's |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
176 ;; arguably a bug because the point with `eval-when-compile' is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
177 ;; that it should evaluate rather than compile its contents. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
178 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
179 ;; We get around it by expanding the body to a quoted |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
180 ;; constant that we eval. That otoh introduce a problem in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
181 ;; that a returned lambda expression doesn't get byte |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
182 ;; compiled (even if `function' is used). |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
183 (eval '(let ((c-inside-eval-when-compile t)) ,@body))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
184 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
185 (put 'cc-eval-when-compile 'lisp-indent-hook 0)) |
24282 | 186 |
187 | |
36920 | 188 ;;; Macros. |
189 | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
190 (defmacro c-point (position &optional point) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
191 "Return the value of certain commonly referenced POSITIONs relative to POINT. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
192 The current point is used if POINT isn't specified. POSITION can be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
193 one of the following symbols: |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
194 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
195 `bol' -- beginning of line |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
196 `eol' -- end of line |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
197 `bod' -- beginning of defun |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
198 `eod' -- end of defun |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
199 `boi' -- beginning of indentation |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
200 `ionl' -- indentation of next line |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
201 `iopl' -- indentation of previous line |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
202 `bonl' -- beginning of next line |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
203 `eonl' -- end of next line |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
204 `bopl' -- beginning of previous line |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
205 `eopl' -- end of previous line |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
206 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
207 If the referenced position doesn't exist, the closest accessible point |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
208 to it is returned. This function does not modify point or mark. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
209 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
210 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
211 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
212 (if (eq (car-safe position) 'quote) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
213 (let ((position (eval position))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
214 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
215 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
216 ((eq position 'bol) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
217 (if (and (fboundp 'line-beginning-position) (not point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
218 `(line-beginning-position) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
219 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
220 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
221 (beginning-of-line) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
222 (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
223 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
224 ((eq position 'eol) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
225 (if (and (fboundp 'line-end-position) (not point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
226 `(line-end-position) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
227 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
228 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
229 (end-of-line) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
230 (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
231 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
232 ((eq position 'boi) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
233 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
234 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
235 (back-to-indentation) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
236 (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
237 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
238 ((eq position 'bod) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
239 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
240 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
241 (c-beginning-of-defun-1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
242 (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
243 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
244 ((eq position 'eod) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
245 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
246 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
247 (c-end-of-defun-1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
248 (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
249 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
250 ((eq position 'bopl) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
251 (if (and (fboundp 'line-beginning-position) (not point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
252 `(line-beginning-position 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
253 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
254 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
255 (forward-line -1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
256 (point)))) |
36920 | 257 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
258 ((eq position 'bonl) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
259 (if (and (fboundp 'line-beginning-position) (not point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
260 `(line-beginning-position 2) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
261 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
262 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
263 (forward-line 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
264 (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
265 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
266 ((eq position 'eopl) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
267 (if (and (fboundp 'line-end-position) (not point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
268 `(line-end-position 0) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
269 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
270 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
271 (beginning-of-line) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
272 (or (bobp) (backward-char)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
273 (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
274 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
275 ((eq position 'eonl) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
276 (if (and (fboundp 'line-end-position) (not point)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
277 `(line-end-position 2) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
278 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
279 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
280 (forward-line 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
281 (end-of-line) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
282 (point)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
283 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
284 ((eq position 'iopl) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
285 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
286 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
287 (forward-line -1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
288 (back-to-indentation) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
289 (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
290 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
291 ((eq position 'ionl) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
292 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
293 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
294 (forward-line 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
295 (back-to-indentation) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
296 (point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
297 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
298 (t (error "Unknown buffer position requested: %s" position)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
299 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
300 ;;(message "c-point long expansion") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
301 `(save-excursion |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
302 ,@(if point `((goto-char ,point))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
303 (let ((position ,position)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
304 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
305 ((eq position 'bol) (beginning-of-line)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
306 ((eq position 'eol) (end-of-line)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
307 ((eq position 'boi) (back-to-indentation)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
308 ((eq position 'bod) (c-beginning-of-defun-1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
309 ((eq position 'eod) (c-end-of-defun-1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
310 ((eq position 'bopl) (forward-line -1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
311 ((eq position 'bonl) (forward-line 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
312 ((eq position 'eopl) (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
313 (beginning-of-line) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
314 (or (bobp) (backward-char)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
315 ((eq position 'eonl) (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
316 (forward-line 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
317 (end-of-line))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
318 ((eq position 'iopl) (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
319 (forward-line -1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
320 (back-to-indentation))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
321 ((eq position 'ionl) (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
322 (forward-line 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
323 (back-to-indentation))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
324 (t (error "Unknown buffer position requested: %s" position)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
325 (point)))) |
18720 | 326 |
327 (defmacro c-safe (&rest body) | |
328 ;; safely execute BODY, return nil if an error occurred | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
329 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
330 ;; This function does not do any hidden buffer changes. |
26817 | 331 `(condition-case nil |
332 (progn ,@body) | |
333 (error nil))) | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
334 (put 'c-safe 'lisp-indent-function 0) |
26817 | 335 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
336 ;; The following is essentially `save-buffer-state' from lazy-lock.el. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
337 ;; It ought to be a standard macro. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
338 (defmacro c-save-buffer-state (varlist &rest body) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
339 "Bind variables according to VARLIST (in `let*' style) and eval BODY, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
340 then restore the buffer state under the assumption that no significant |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
341 modification has been made. A change is considered significant if it |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
342 affects the buffer text in any way that isn't completely restored |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
343 again. Changes in text properties like `face' or `syntax-table' are |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
344 considered insignificant. This macro allows text properties to be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
345 changed, even in a read-only buffer. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
346 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
347 The return value is the value of the last form in BODY." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
348 `(let* ((modified (buffer-modified-p)) (buffer-undo-list t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
349 (inhibit-read-only t) (inhibit-point-motion-hooks t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
350 before-change-functions after-change-functions |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
351 deactivate-mark |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
352 ,@varlist) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
353 (prog1 (progn ,@body) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
354 (and (not modified) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
355 (buffer-modified-p) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
356 (set-buffer-modified-p nil))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
357 (put 'c-save-buffer-state 'lisp-indent-function 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
358 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
359 (defmacro c-forward-syntactic-ws (&optional limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
360 "Forward skip over syntactic whitespace. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
361 Syntactic whitespace is defined as whitespace characters, comments, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
362 and preprocessor directives. However if point starts inside a comment |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
363 or preprocessor directive, the content of it is not treated as |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
364 whitespace. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
365 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
366 LIMIT sets an upper limit of the forward movement, if specified. If |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
367 LIMIT or the end of the buffer is reached inside a comment or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
368 preprocessor directive, the point will be left there. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
369 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
370 Note that this function might do hidden buffer changes. See the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
371 comment at the start of cc-engine.el for more info." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
372 (if limit |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
373 `(save-restriction |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
374 (narrow-to-region (point-min) (or ,limit (point-max))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
375 (c-forward-sws)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
376 '(c-forward-sws))) |
36920 | 377 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
378 (defmacro c-backward-syntactic-ws (&optional limit) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
379 "Backward skip over syntactic whitespace. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
380 Syntactic whitespace is defined as whitespace characters, comments, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
381 and preprocessor directives. However if point starts inside a comment |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
382 or preprocessor directive, the content of it is not treated as |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
383 whitespace. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
384 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
385 LIMIT sets a lower limit of the backward movement, if specified. If |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
386 LIMIT is reached inside a line comment or preprocessor directive then |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
387 the point is moved into it past the whitespace at the end. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
388 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
389 Note that this function might do hidden buffer changes. See the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
390 comment at the start of cc-engine.el for more info." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
391 (if limit |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
392 `(save-restriction |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
393 (narrow-to-region (or ,limit (point-min)) (point-max)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
394 (c-backward-sws)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
395 '(c-backward-sws))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
396 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
397 (defmacro c-forward-sexp (&optional count) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
398 "Move forward across COUNT balanced expressions. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
399 A negative COUNT means move backward. Signal an error if the move |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
400 fails for any reason. |
36920 | 401 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
402 This is like `forward-sexp' except that it isn't interactive and does |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
403 not do any user friendly adjustments of the point and that it isn't |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
404 susceptible to user configurations such as disabling of signals in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
405 certain situations. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
406 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
407 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
408 (or count (setq count 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
409 `(goto-char (or (scan-sexps (point) ,count) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
410 ,(if (numberp count) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
411 (if (> count 0) `(point-max) `(point-min)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
412 `(if (> ,count 0) (point-max) (point-min)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
413 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
414 (defmacro c-backward-sexp (&optional count) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
415 "See `c-forward-sexp' and reverse directions." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
416 (or count (setq count 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
417 `(c-forward-sexp ,(if (numberp count) (- count) `(- ,count)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
418 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
419 (defmacro c-safe-scan-lists (from count depth) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
420 "Like `scan-lists' but returns nil instead of signalling errors. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
421 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
422 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
423 (if (featurep 'xemacs) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
424 `(scan-lists ,from ,count ,depth nil t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
425 `(c-safe (scan-lists ,from ,count ,depth)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
426 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
427 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
428 ;; Wrappers for common scan-lists cases, mainly because it's almost |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
429 ;; impossible to get a feel for how that function works. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
430 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
431 (defmacro c-up-list-forward (&optional pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
432 "Return the first position after the list sexp containing POS, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
433 or nil if no such position exists. The point is used if POS is left out. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
434 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
435 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
436 `(c-safe-scan-lists ,(or pos `(point)) 1 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
437 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
438 (defmacro c-up-list-backward (&optional pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
439 "Return the position of the start of the list sexp containing POS, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
440 or nil if no such position exists. The point is used if POS is left out. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
441 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
442 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
443 `(c-safe-scan-lists ,(or pos `(point)) -1 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
444 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
445 (defmacro c-down-list-forward (&optional pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
446 "Return the first position inside the first list sexp after POS, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
447 or nil if no such position exists. The point is used if POS is left out. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
448 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
449 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
450 `(c-safe-scan-lists ,(or pos `(point)) 1 -1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
451 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
452 (defmacro c-down-list-backward (&optional pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
453 "Return the last position inside the last list sexp before POS, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
454 or nil if no such position exists. The point is used if POS is left out. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
455 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
456 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
457 `(c-safe-scan-lists ,(or pos `(point)) -1 -1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
458 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
459 (defmacro c-go-up-list-forward (&optional pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
460 "Move the point to the first position after the list sexp containing POS, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
461 or the point if POS is left out. Return t if such a position exists, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
462 otherwise nil is returned and the point isn't moved. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
463 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
464 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
465 `(c-safe (goto-char (scan-lists ,(or pos `(point)) 1 1)) t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
466 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
467 (defmacro c-go-up-list-backward (&optional pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
468 "Move the point to the position of the start of the list sexp containing POS, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
469 or the point if POS is left out. Return t if such a position exists, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
470 otherwise nil is returned and the point isn't moved. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
471 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
472 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
473 `(c-safe (goto-char (scan-lists ,(or pos `(point)) -1 1)) t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
474 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
475 (defmacro c-go-down-list-forward (&optional pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
476 "Move the point to the first position inside the first list sexp after POS, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
477 or the point if POS is left out. Return t if such a position exists, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
478 otherwise nil is returned and the point isn't moved. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
479 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
480 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
481 `(c-safe (goto-char (scan-lists ,(or pos `(point)) 1 -1)) t)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
482 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
483 (defmacro c-go-down-list-backward (&optional pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
484 "Move the point to the last position inside the last list sexp before POS, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
485 or the point if POS is left out. Return t if such a position exists, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
486 otherwise nil is returned and the point isn't moved. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
487 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
488 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
489 `(c-safe (goto-char (scan-lists ,(or pos `(point)) -1 -1)) t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
490 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
491 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
492 (defmacro c-beginning-of-defun-1 () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
493 ;; Wrapper around beginning-of-defun. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
494 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
495 ;; NOTE: This function should contain the only explicit use of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
496 ;; beginning-of-defun in CC Mode. Eventually something better than |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
497 ;; b-o-d will be available and this should be the only place the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
498 ;; code needs to change. Everything else should use |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
499 ;; (c-beginning-of-defun-1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
500 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
501 ;; This is really a bit too large to be a macro but that isn't a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
502 ;; problem as long as it only is used in one place in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
503 ;; `c-parse-state'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
504 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
505 ;; This function does not do any hidden buffer changes. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
506 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
507 `(progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
508 (if (and ,(cc-bytecomp-fboundp 'buffer-syntactic-context-depth) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
509 c-enable-xemacs-performance-kludge-p) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
510 ,(when (cc-bytecomp-fboundp 'buffer-syntactic-context-depth) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
511 ;; XEmacs only. This can improve the performance of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
512 ;; c-parse-state to between 3 and 60 times faster when |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
513 ;; braces are hung. It can also degrade performance by |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
514 ;; about as much when braces are not hung. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
515 '(let (pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
516 (while (not pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
517 (save-restriction |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
518 (widen) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
519 (setq pos (c-safe-scan-lists |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
520 (point) -1 (buffer-syntactic-context-depth)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
521 (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
522 ((bobp) (setq pos (point-min))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
523 ((not pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
524 (let ((distance (skip-chars-backward "^{"))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
525 ;; unbalanced parenthesis, while illegal C code, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
526 ;; shouldn't cause an infloop! See unbal.c |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
527 (when (zerop distance) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
528 ;; Punt! |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
529 (beginning-of-defun) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
530 (setq pos (point))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
531 ((= pos 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
532 ((not (eq (char-after pos) ?{)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
533 (goto-char pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
534 (setq pos nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
535 )) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
536 (goto-char pos))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
537 ;; Emacs, which doesn't have buffer-syntactic-context-depth |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
538 (beginning-of-defun)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
539 ;; if defun-prompt-regexp is non-nil, b-o-d won't leave us at the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
540 ;; open brace. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
541 (and defun-prompt-regexp |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
542 (looking-at defun-prompt-regexp) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
543 (goto-char (match-end 0))))) |
36920 | 544 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
545 (defmacro c-benign-error (format &rest args) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
546 ;; Formats an error message for the echo area and dings, i.e. like |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
547 ;; `error' but doesn't abort. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
548 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
549 ;; This function does not do any hidden buffer changes. |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
550 `(progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
551 (message ,format ,@args) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
552 (ding))) |
36920 | 553 |
554 (defmacro c-update-modeline () | |
555 ;; set the c-auto-hungry-string for the correct designation on the modeline | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
556 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
557 ;; This function does not do any hidden buffer changes. |
36920 | 558 `(progn |
559 (setq c-auto-hungry-string | |
560 (if c-auto-newline | |
561 (if c-hungry-delete-key "/ah" "/a") | |
562 (if c-hungry-delete-key "/h" nil))) | |
563 (force-mode-line-update))) | |
564 | |
565 (defmacro c-with-syntax-table (table &rest code) | |
566 ;; Temporarily switches to the specified syntax table in a failsafe | |
567 ;; way to execute code. | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
568 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
569 ;; This function does not do any hidden buffer changes. |
36920 | 570 `(let ((c-with-syntax-table-orig-table (syntax-table))) |
571 (unwind-protect | |
572 (progn | |
573 (set-syntax-table ,table) | |
574 ,@code) | |
575 (set-syntax-table c-with-syntax-table-orig-table)))) | |
576 (put 'c-with-syntax-table 'lisp-indent-function 1) | |
577 | |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
578 (defmacro c-skip-ws-forward (&optional limit) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
579 "Skip over any whitespace following point. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
580 This function skips over horizontal and vertical whitespace and line |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
581 continuations. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
582 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
583 This function does not do any hidden buffer changes." |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
584 (if limit |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
585 `(let ((limit (or ,limit (point-max)))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
586 (while (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
587 ;; skip-syntax-* doesn't count \n as whitespace.. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
588 (skip-chars-forward " \t\n\r\f\v" limit) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
589 (when (and (eq (char-after) ?\\) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
590 (< (point) limit)) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
591 (forward-char) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
592 (or (eolp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
593 (progn (backward-char) nil)))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
594 '(while (progn |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
595 (skip-chars-forward " \t\n\r\f\v") |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
596 (when (eq (char-after) ?\\) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
597 (forward-char) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
598 (or (eolp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
599 (progn (backward-char) nil))))))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
600 |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
601 (defmacro c-skip-ws-backward (&optional limit) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
602 "Skip over any whitespace preceding point. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
603 This function skips over horizontal and vertical whitespace and line |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
604 continuations. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
605 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
606 This function does not do any hidden buffer changes." |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
607 (if limit |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
608 `(let ((limit (or ,limit (point-min)))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
609 (while (progn |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
610 ;; skip-syntax-* doesn't count \n as whitespace.. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
611 (skip-chars-backward " \t\n\r\f\v" limit) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
612 (and (eolp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
613 (eq (char-before) ?\\) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
614 (> (point) limit))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
615 (backward-char))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
616 '(while (progn |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
617 (skip-chars-backward " \t\n\r\f\v") |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
618 (and (eolp) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
619 (eq (char-before) ?\\))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
620 (backward-char)))) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
621 |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
622 (eval-and-compile |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
623 (defvar c-langs-are-parametric nil)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
624 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
625 (defmacro c-major-mode-is (mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
626 "Return non-nil if the current CC Mode major mode is MODE. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
627 MODE is either a mode symbol or a list of mode symbols. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
628 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
629 This function does not do any hidden buffer changes." |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
630 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
631 (if c-langs-are-parametric |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
632 ;; Inside a `c-lang-defconst'. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
633 `(c-lang-major-mode-is ,mode) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
634 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
635 (if (eq (car-safe mode) 'quote) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
636 (let ((mode (eval mode))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
637 (if (listp mode) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
638 `(memq c-buffer-is-cc-mode ',mode) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
639 `(eq c-buffer-is-cc-mode ',mode))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
640 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
641 `(let ((mode ,mode)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
642 (if (listp mode) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
643 (memq c-buffer-is-cc-mode mode) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
644 (eq c-buffer-is-cc-mode mode)))))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
645 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
646 (defmacro c-mode-is-new-awk-p () |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
647 ;; Is the current mode the "new" awk mode? It is important for |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
648 ;; (e.g.) the cc-engine functions do distinguish between the old and |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
649 ;; new awk-modes. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
650 '(and (c-major-mode-is 'awk-mode) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
651 (memq 'syntax-properties c-emacs-features))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
652 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
653 (defmacro c-parse-sexp-lookup-properties () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
654 ;; Return the value of the variable that says whether the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
655 ;; syntax-table property affects the sexp routines. Always return |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
656 ;; nil in (X)Emacsen without support for that. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
657 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
658 ;; This function does not do any hidden buffer changes. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
659 (cond ((cc-bytecomp-boundp 'parse-sexp-lookup-properties) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
660 `parse-sexp-lookup-properties) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
661 ((cc-bytecomp-boundp 'lookup-syntax-properties) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
662 `lookup-syntax-properties) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
663 (t nil))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
664 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
665 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
666 ;; Macros/functions to handle so-called "char properties", which are |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
667 ;; properties set on a single character and that never spreads to any |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
668 ;; other characters. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
669 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
670 (eval-and-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
671 ;; Constant used at compile time to decide whether or not to use |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
672 ;; XEmacs extents. Check all the extent functions we'll use since |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
673 ;; some packages might add compatibility aliases for some of them in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
674 ;; Emacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
675 (defconst c-use-extents (and (cc-bytecomp-fboundp 'extent-at) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
676 (cc-bytecomp-fboundp 'set-extent-property) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
677 (cc-bytecomp-fboundp 'set-extent-properties) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
678 (cc-bytecomp-fboundp 'make-extent) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
679 (cc-bytecomp-fboundp 'extent-property) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
680 (cc-bytecomp-fboundp 'delete-extent) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
681 (cc-bytecomp-fboundp 'map-extents)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
682 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
683 ;; `c-put-char-property' is complex enough in XEmacs and Emacs < 21 to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
684 ;; make it a function. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
685 (defalias 'c-put-char-property-fun |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
686 (cc-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
687 (cond (c-use-extents |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
688 ;; XEmacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
689 (byte-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
690 (lambda (pos property value) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
691 (let ((ext (extent-at pos nil property))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
692 (if ext |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
693 (set-extent-property ext property value) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
694 (set-extent-properties (make-extent pos (1+ pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
695 (cons property |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
696 (cons value |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
697 '(start-open t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
698 end-open t))))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
699 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
700 ((not (cc-bytecomp-boundp 'text-property-default-nonsticky)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
701 ;; In Emacs < 21 we have to mess with the `rear-nonsticky' property. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
702 (byte-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
703 (lambda (pos property value) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
704 (put-text-property pos (1+ pos) property value) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
705 (let ((prop (get-text-property pos 'rear-nonsticky))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
706 (or (memq property prop) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
707 (put-text-property pos (1+ pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
708 'rear-nonsticky |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
709 (cons property prop)))))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
710 (cc-bytecomp-defun c-put-char-property-fun) ; Make it known below. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
711 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
712 (defmacro c-put-char-property (pos property value) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
713 ;; Put the given property with the given value on the character at |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
714 ;; POS and make it front and rear nonsticky, or start and end open |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
715 ;; in XEmacs vocabulary. If the character already has the given |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
716 ;; property then the value is replaced, and the behavior is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
717 ;; undefined if that property has been put by some other function. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
718 ;; PROPERTY is assumed to be constant. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
719 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
720 ;; If there's a `text-property-default-nonsticky' variable (Emacs |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
721 ;; 21) then it's assumed that the property is present on it. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
722 (setq property (eval property)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
723 (if (or c-use-extents |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
724 (not (cc-bytecomp-boundp 'text-property-default-nonsticky))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
725 ;; XEmacs and Emacs < 21. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
726 `(c-put-char-property-fun ,pos ',property ,value) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
727 ;; In Emacs 21 we got the `rear-nonsticky' property covered |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
728 ;; by `text-property-default-nonsticky'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
729 `(let ((-pos- ,pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
730 (put-text-property -pos- (1+ -pos-) ',property ,value)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
731 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
732 (defmacro c-get-char-property (pos property) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
733 ;; Get the value of the given property on the character at POS if |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
734 ;; it's been put there by `c-put-char-property'. PROPERTY is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
735 ;; assumed to be constant. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
736 (setq property (eval property)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
737 (if c-use-extents |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
738 ;; XEmacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
739 `(let ((ext (extent-at ,pos nil ',property))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
740 (if ext (extent-property ext ',property))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
741 ;; Emacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
742 `(get-text-property ,pos ',property))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
743 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
744 ;; `c-clear-char-property' is complex enough in Emacs < 21 to make it |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
745 ;; a function, since we have to mess with the `rear-nonsticky' property. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
746 (defalias 'c-clear-char-property-fun |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
747 (cc-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
748 (unless (or c-use-extents |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
749 (cc-bytecomp-boundp 'text-property-default-nonsticky)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
750 (byte-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
751 (lambda (pos property) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
752 (when (get-text-property pos property) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
753 (remove-text-properties pos (1+ pos) (list property nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
754 (put-text-property pos (1+ pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
755 'rear-nonsticky |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
756 (delq property (get-text-property |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
757 pos 'rear-nonsticky))))))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
758 (cc-bytecomp-defun c-clear-char-property-fun) ; Make it known below. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
759 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
760 (defmacro c-clear-char-property (pos property) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
761 ;; Remove the given property on the character at POS if it's been put |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
762 ;; there by `c-put-char-property'. PROPERTY is assumed to be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
763 ;; constant. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
764 (setq property (eval property)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
765 (cond (c-use-extents |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
766 ;; XEmacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
767 `(let ((ext (extent-at ,pos nil ',property))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
768 (if ext (delete-extent ext)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
769 ((cc-bytecomp-boundp 'text-property-default-nonsticky) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
770 ;; In Emacs 21 we got the `rear-nonsticky' property covered |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
771 ;; by `text-property-default-nonsticky'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
772 `(let ((pos ,pos)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
773 (remove-text-properties pos (1+ pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
774 '(,property nil)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
775 (t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
776 ;; Emacs < 21. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
777 `(c-clear-char-property-fun ,pos ',property)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
778 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
779 (defmacro c-clear-char-properties (from to property) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
780 ;; Remove all the occurences of the given property in the given |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
781 ;; region that has been put with `c-put-char-property'. PROPERTY is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
782 ;; assumed to be constant. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
783 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
784 ;; Note that this function does not clean up the property from the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
785 ;; lists of the `rear-nonsticky' properties in the region, if such |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
786 ;; are used. Thus it should not be used for common properties like |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
787 ;; `syntax-table'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
788 (setq property (eval property)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
789 (if c-use-extents |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
790 ;; XEmacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
791 `(map-extents (lambda (ext ignored) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
792 (delete-extent ext)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
793 nil ,from ,to nil nil ',property) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
794 ;; Emacs. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
795 `(remove-text-properties ,from ,to '(,property nil)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
796 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
797 |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
798 ;; Make edebug understand the macros. |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
799 (eval-after-load "edebug" |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
800 '(progn |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
801 (def-edebug-spec c-point t) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
802 (def-edebug-spec c-safe t) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
803 (def-edebug-spec c-save-buffer-state let*) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
804 (def-edebug-spec c-forward-syntactic-ws t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
805 (def-edebug-spec c-backward-syntactic-ws t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
806 (def-edebug-spec c-forward-sexp t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
807 (def-edebug-spec c-backward-sexp t) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
808 (def-edebug-spec c-up-list-forward t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
809 (def-edebug-spec c-up-list-backward t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
810 (def-edebug-spec c-down-list-forward t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
811 (def-edebug-spec c-down-list-backward t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
812 (def-edebug-spec c-add-syntax t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
813 (def-edebug-spec c-add-class-syntax t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
814 (def-edebug-spec c-benign-error t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
815 (def-edebug-spec c-with-syntax-table t) |
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
816 (def-edebug-spec c-skip-ws-forward t) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
817 (def-edebug-spec c-skip-ws-backward t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
818 (def-edebug-spec c-major-mode-is t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
819 (def-edebug-spec c-put-char-property t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
820 (def-edebug-spec c-get-char-property t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
821 (def-edebug-spec c-clear-char-property t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
822 (def-edebug-spec c-clear-char-properties t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
823 (def-edebug-spec cc-eval-when-compile t))) |
44728
7a3ac6c387fe
CC Mode update to version 5.29. This is for testing; it's not a released
Martin Stjernholm <mast@lysator.liu.se>
parents:
38422
diff
changeset
|
824 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
825 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
826 ;;; Functions. |
36920 | 827 |
828 ;; Note: All these after the macros, to be on safe side in avoiding | |
829 ;; bugs where macros are defined too late. These bugs often only show | |
830 ;; when the files are compiled in a certain order within the same | |
831 ;; session. | |
832 | |
26817 | 833 (defsubst c-end-of-defun-1 () |
834 ;; Replacement for end-of-defun that use c-beginning-of-defun-1. | |
30404
3393922ea102
(c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
835 (let ((start (point))) |
3393922ea102
(c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
836 ;; Skip forward into the next defun block. Don't bother to avoid |
3393922ea102
(c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
837 ;; comments, literals etc, since beginning-of-defun doesn't do that |
3393922ea102
(c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
838 ;; anyway. |
3393922ea102
(c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
839 (skip-chars-forward "^}") |
3393922ea102
(c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
840 (c-beginning-of-defun-1) |
3393922ea102
(c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
841 (if (eq (char-after) ?{) |
3393922ea102
(c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
842 (c-forward-sexp)) |
3393922ea102
(c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
843 (if (< (point) start) |
3393922ea102
(c-end-of-defun-1): Fixed forward scanning into
Gerd Moellmann <gerd@gnu.org>
parents:
26817
diff
changeset
|
844 (goto-char (point-max))))) |
18720 | 845 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
846 (defconst c-<-as-paren-syntax '(4 . ?>)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
847 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
848 (defsubst c-mark-<-as-paren (pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
849 ;; Mark the "<" character at POS as an sexp list opener using the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
850 ;; syntax-table property. Note that Emacs 19 and XEmacs <= 20 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
851 ;; doesn't support syntax properties, so this function might not |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
852 ;; have any effect. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
853 (c-put-char-property pos 'syntax-table c-<-as-paren-syntax)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
854 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
855 (defconst c->-as-paren-syntax '(5 . ?<)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
856 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
857 (defsubst c-mark->-as-paren (pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
858 ;; Mark the ">" character at POS as an sexp list closer using the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
859 ;; syntax-table property. Note that Emacs 19 and XEmacs <= 20 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
860 ;; doesn't support syntax properties, so this function might not |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
861 ;; have any effect. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
862 (c-put-char-property pos 'syntax-table c->-as-paren-syntax)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
863 |
18720 | 864 (defsubst c-intersect-lists (list alist) |
865 ;; return the element of ALIST that matches the first element found | |
866 ;; in LIST. Uses assq. | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
867 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
868 ;; This function does not do any hidden buffer changes. |
18720 | 869 (let (match) |
870 (while (and list | |
871 (not (setq match (assq (car list) alist)))) | |
872 (setq list (cdr list))) | |
873 match)) | |
874 | |
875 (defsubst c-lookup-lists (list alist1 alist2) | |
876 ;; first, find the first entry from LIST that is present in ALIST1, | |
877 ;; then find the entry in ALIST2 for that entry. | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
878 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
879 ;; This function does not do any hidden buffer changes. |
18720 | 880 (assq (car (c-intersect-lists list alist1)) alist2)) |
881 | |
51948
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
882 (defsubst c-langelem-sym (langelem) |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
883 "Return the syntactic symbol in LANGELEM. |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
884 |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
885 LANGELEM is a syntactic element, i.e. either a cons cell on the |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
886 \"old\" form given as the first argument to lineup functions or a list |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
887 on the \"new\" form as used in `c-syntactic-element'. |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
888 |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
889 This function does not do any hidden buffer changes." |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
890 (car langelem)) |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
891 |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
892 (defsubst c-langelem-pos (langelem) |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
893 "Return the (primary) anchor position in LANGELEM, or nil if there is none. |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
894 |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
895 LANGELEM is a syntactic element, i.e. either a cons cell on the |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
896 \"old\" form given as the first argument to lineup functions or a list |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
897 on the \"new\" form as used in `c-syntactic-element'. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
898 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
899 This function does not do any hidden buffer changes." |
51948
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
900 (if (consp (cdr langelem)) |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
901 (car-safe (cdr langelem)) |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
902 (cdr langelem))) |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
903 |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
904 (defun c-langelem-col (langelem &optional preserve-point) |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
905 "Return the column of the (primary) anchor position in LANGELEM. |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
906 Leave point at that position unless PRESERVE-POINT is non-nil. |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
907 |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
908 LANGELEM is a syntactic element, i.e. either a cons cell on the |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
909 \"old\" form given as the first argument to lineup functions or a list |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
910 on the \"new\" form as used in `c-syntactic-element'. |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
911 |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
912 This function does not do any hidden buffer changes." |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
913 (let ((pos (c-langelem-pos langelem)) |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
914 (here (point))) |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
915 (if pos |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
916 (progn |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
917 (goto-char pos) |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
918 (prog1 (current-column) |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
919 (if preserve-point |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
920 (goto-char here)))) |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
921 0))) |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
922 |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
923 (defsubst c-langelem-2nd-pos (langelem) |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
924 "Return the secondary position in LANGELEM, or nil if there is none. |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
925 |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
926 LANGELEM is a syntactic element, typically on the \"new\" form as used |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
927 in `c-syntactic-element'. It may be on the \"old\" form that is used |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
928 as the first argument to lineup functions, but then the returned value |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
929 always will be nil. |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
930 |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
931 This function does not do any hidden buffer changes." |
b881031be46c
(c-langelem-sym, c-langelem-pos, c-langelem-2nd-pos): Added accessor
Martin Stjernholm <mast@lysator.liu.se>
parents:
51887
diff
changeset
|
932 (car-safe (cdr-safe (cdr-safe langelem)))) |
18720 | 933 |
934 (defsubst c-keep-region-active () | |
935 ;; Do whatever is necessary to keep the region active in XEmacs. | |
36920 | 936 ;; This is not needed for Emacs. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
937 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
938 ;; This function does not do any hidden buffer changes. |
18720 | 939 (and (boundp 'zmacs-region-stays) |
940 (setq zmacs-region-stays t))) | |
941 | |
24282 | 942 (defsubst c-region-is-active-p () |
943 ;; Return t when the region is active. The determination of region | |
944 ;; activeness is different in both Emacs and XEmacs. | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
945 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
946 ;; This function does not do any hidden buffer changes. |
24282 | 947 (cond |
948 ;; XEmacs | |
949 ((and (fboundp 'region-active-p) | |
26817 | 950 (boundp 'zmacs-regions) |
24282 | 951 zmacs-regions) |
952 (region-active-p)) | |
953 ;; Emacs | |
954 ((boundp 'mark-active) mark-active) | |
955 ;; fallback; shouldn't get here | |
956 (t (mark t)))) | |
957 | |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
958 (put 'c-mode 'c-mode-prefix "c-") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
959 (put 'c++-mode 'c-mode-prefix "c++-") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
960 (put 'objc-mode 'c-mode-prefix "objc-") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
961 (put 'java-mode 'c-mode-prefix "java-") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
962 (put 'idl-mode 'c-mode-prefix "idl-") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
963 (put 'pike-mode 'c-mode-prefix "pike-") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
964 (put 'awk-mode 'c-mode-prefix "awk-") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
965 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
966 (defsubst c-mode-symbol (suffix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
967 "Prefix the current mode prefix (e.g. \"c-\") to SUFFIX and return |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
968 the corresponding symbol. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
969 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
970 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
971 (or c-buffer-is-cc-mode |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
972 (error "Not inside a CC Mode based mode")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
973 (let ((mode-prefix (get c-buffer-is-cc-mode 'c-mode-prefix))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
974 (or mode-prefix |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
975 (error "%S has no mode prefix known to `c-mode-symbol'" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
976 c-buffer-is-cc-mode)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
977 (intern (concat mode-prefix suffix)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
978 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
979 (defsubst c-mode-var (suffix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
980 "Prefix the current mode prefix (e.g. \"c-\") to SUFFIX and return |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
981 the value of the variable with that name. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
982 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
983 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
984 (symbol-value (c-mode-symbol suffix))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
985 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
986 (defsubst c-got-face-at (pos faces) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
987 "Return non-nil if position POS in the current buffer has any of the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
988 faces in the list FACES. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
989 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
990 This function does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
991 (let ((pos-faces (get-text-property pos 'face))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
992 (if (consp pos-faces) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
993 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
994 (while (and pos-faces |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
995 (not (memq (car pos-faces) faces))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
996 (setq pos-faces (cdr pos-faces))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
997 pos-faces) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
998 (memq pos-faces faces)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
999 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1000 (defsubst c-face-name-p (facename) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1001 ;; Return t if FACENAME is the name of a face. This method is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1002 ;; necessary since facep in XEmacs only returns t for the actual |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1003 ;; face objects (while it's only their names that are used just |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1004 ;; about anywhere else) without providing a predicate that tests |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1005 ;; face names. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1006 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1007 ;; This function does not do any hidden buffer changes. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1008 (memq facename (face-list))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1009 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1010 (defun c-make-keywords-re (adorn list &optional mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1011 "Make a regexp that matches all the strings the list. |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1012 Duplicates in the list are removed. The resulting regexp may contain |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1013 zero or more submatch expressions. |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1014 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1015 If ADORN is non-nil there will be at least one submatch and the first |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1016 matches the whole keyword, and the regexp will also not match a prefix |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1017 of any identifier. Adorned regexps cannot be appended. The language |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1018 variable `c-nonsymbol-key' is used to make the adornment. The |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1019 optional MODE specifies the language to get it in. The default is the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1020 current language (taken from `c-buffer-is-cc-mode')." |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1021 |
51887
a39d64d1eb50
(c-make-keywords-re): Don't use delete-duplicates.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
1022 (let (unique) |
a39d64d1eb50
(c-make-keywords-re): Don't use delete-duplicates.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
1023 (dolist (elt list) |
a39d64d1eb50
(c-make-keywords-re): Don't use delete-duplicates.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
1024 (unless (member elt unique) |
a39d64d1eb50
(c-make-keywords-re): Don't use delete-duplicates.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
1025 (push elt unique))) |
a39d64d1eb50
(c-make-keywords-re): Don't use delete-duplicates.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
1026 (setq list unique)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1027 (if list |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1028 (let ((re (c-regexp-opt list))) |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1029 |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1030 ;; Emacs < 21 and XEmacs (all versions so far) has a buggy |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1031 ;; regexp-opt that doesn't always cope with strings containing |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1032 ;; newlines. This kludge doesn't handle shy parens correctly |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1033 ;; so we can't advice regexp-opt directly with it. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1034 (let (fail-list) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1035 (while list |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1036 (and (string-match "\n" (car list)) ; To speed it up a little. |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1037 (not (string-match (concat "\\`\\(" re "\\)\\'") |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1038 (car list))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1039 (setq fail-list (cons (car list) fail-list))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1040 (setq list (cdr list))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1041 (when fail-list |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1042 (setq re (concat re |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1043 "\\|" |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1044 (mapconcat 'regexp-quote |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1045 (sort fail-list |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1046 (lambda (a b) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1047 (> (length a) (length b)))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1048 "\\|"))))) |
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1049 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1050 ;; Add our own grouping parenthesis around re instead of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1051 ;; passing adorn to `regexp-opt', since in XEmacs it makes the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1052 ;; top level grouping "shy". |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1053 (if adorn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1054 (concat "\\(" re "\\)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1055 "\\(" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1056 (c-get-lang-constant 'c-nonsymbol-key nil mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1057 "\\|$\\)") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1058 re)) |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1059 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1060 ;; Produce a regexp that matches nothing. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1061 (if adorn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1062 "\\(\\<\\>\\)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1063 "\\<\\>"))) |
53073
49f65e04ba8e
CC Mode update (5.30.8).
Martin Stjernholm <mast@lysator.liu.se>
parents:
52610
diff
changeset
|
1064 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1065 (put 'c-make-keywords-re 'lisp-indent-function 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1066 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1067 |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1068 ;; Figure out what features this Emacs has |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1069 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1070 (cc-bytecomp-defvar open-paren-in-column-0-is-defun-start) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1071 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1072 (defconst c-emacs-features |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1073 (let (list) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1074 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1075 (if (boundp 'infodock-version) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1076 ;; I've no idea what this actually is, but it's legacy. /mast |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1077 (setq list (cons 'infodock list))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1078 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1079 ;; XEmacs 19 and beyond use 8-bit modify-syntax-entry flags. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1080 ;; Emacs 19 uses a 1-bit flag. We will have to set up our |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1081 ;; syntax tables differently to handle this. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1082 (let ((table (copy-syntax-table)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1083 entry) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1084 (modify-syntax-entry ?a ". 12345678" table) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1085 (cond |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1086 ;; XEmacs 19, and beyond Emacs 19.34 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1087 ((arrayp table) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1088 (setq entry (aref table ?a)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1089 ;; In Emacs, table entries are cons cells |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1090 (if (consp entry) (setq entry (car entry)))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1091 ;; XEmacs 20 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1092 ((fboundp 'get-char-table) (setq entry (get-char-table ?a table))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1093 ;; before and including Emacs 19.34 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1094 ((and (fboundp 'char-table-p) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1095 (char-table-p table)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1096 (setq entry (car (char-table-range table [?a])))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1097 ;; incompatible |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1098 (t (error "CC Mode is incompatible with this version of Emacs"))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1099 (setq list (cons (if (= (logand (lsh entry -16) 255) 255) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1100 '8-bit |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1101 '1-bit) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1102 list))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1103 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1104 (let ((buf (generate-new-buffer " test")) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1105 parse-sexp-lookup-properties |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1106 parse-sexp-ignore-comments |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1107 lookup-syntax-properties) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1108 (save-excursion |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1109 (set-buffer buf) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1110 (set-syntax-table (make-syntax-table)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1111 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1112 ;; For some reason we have to set some of these after the |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1113 ;; buffer has been made current. (Specifically, |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1114 ;; `parse-sexp-ignore-comments' in Emacs 21.) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1115 (setq parse-sexp-lookup-properties t |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1116 parse-sexp-ignore-comments t |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1117 lookup-syntax-properties t) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1118 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1119 ;; Find out if the `syntax-table' text property works. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1120 (modify-syntax-entry ?< ".") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1121 (modify-syntax-entry ?> ".") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1122 (insert "<()>") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1123 (c-mark-<-as-paren 1) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1124 (c-mark->-as-paren 4) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1125 (goto-char 1) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1126 (c-forward-sexp) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1127 (if (= (point) 5) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1128 (setq list (cons 'syntax-properties list))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1129 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1130 ;; Find out if generic comment delimiters work. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1131 (c-safe |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1132 (modify-syntax-entry ?x "!") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1133 (if (string-match "\\s!" "x") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1134 (setq list (cons 'gen-comment-delim list)))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1135 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1136 ;; Find out if generic string delimiters work. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1137 (c-safe |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1138 (modify-syntax-entry ?x "|") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1139 (if (string-match "\\s|" "x") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1140 (setq list (cons 'gen-string-delim list)))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1141 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1142 ;; See if POSIX char classes work. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1143 (when (and (string-match "[[:alpha:]]" "a") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1144 ;; All versions of Emacs 21 so far haven't fixed |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1145 ;; char classes in `skip-chars-forward' and |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1146 ;; `skip-chars-backward'. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1147 (progn |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1148 (delete-region (point-min) (point-max)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1149 (insert "foo123") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1150 (skip-chars-backward "[:alnum:]") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1151 (bobp)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1152 (= (skip-chars-forward "[:alpha:]") 3)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1153 (setq list (cons 'posix-char-classes list))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1154 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1155 ;; See if `open-paren-in-column-0-is-defun-start' exists and |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1156 ;; isn't buggy. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1157 (when (boundp 'open-paren-in-column-0-is-defun-start) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1158 (let ((open-paren-in-column-0-is-defun-start nil) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1159 (parse-sexp-ignore-comments t)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1160 (delete-region (point-min) (point-max)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1161 (set-syntax-table (make-syntax-table)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1162 (modify-syntax-entry ?\' "\"") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1163 (cond |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1164 ;; XEmacs. Afaik this is currently an Emacs-only |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1165 ;; feature, but it's good to be prepared. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1166 ((memq '8-bit list) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1167 (modify-syntax-entry ?/ ". 1456") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1168 (modify-syntax-entry ?* ". 23")) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1169 ;; Emacs |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1170 ((memq '1-bit list) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1171 (modify-syntax-entry ?/ ". 124b") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1172 (modify-syntax-entry ?* ". 23"))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1173 (modify-syntax-entry ?\n "> b") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1174 (insert "/* '\n () */") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1175 (backward-sexp) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1176 (if (bobp) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1177 (setq list (cons 'col-0-paren list))))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1178 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1179 (set-buffer-modified-p nil)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1180 (kill-buffer buf)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1181 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1182 ;; See if `parse-partial-sexp' returns the eighth element. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1183 (when (c-safe (>= (length (save-excursion (parse-partial-sexp 1 1))) 10)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1184 (setq list (cons 'pps-extended-state list))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1185 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1186 ;;(message "c-emacs-features: %S" list) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1187 list) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1188 "A list of certain features in the (X)Emacs you are using. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1189 There are many flavors of Emacs out there, each with different |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1190 features supporting those needed by CC Mode. The following values |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1191 might be present: |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1192 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1193 '8-bit 8 bit syntax entry flags (XEmacs style). |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1194 '1-bit 1 bit syntax entry flags (Emacs style). |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1195 'syntax-properties It works to override the syntax for specific characters |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1196 in the buffer with the 'syntax-table property. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1197 'gen-comment-delim Generic comment delimiters work |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1198 (i.e. the syntax class `!'). |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1199 'gen-string-delim Generic string delimiters work |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1200 (i.e. the syntax class `|'). |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1201 'pps-extended-state `parse-partial-sexp' returns a list with at least 10 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1202 elements, i.e. it contains the position of the |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1203 start of the last comment or string. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1204 'posix-char-classes The regexp engine understands POSIX character classes. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1205 'col-0-paren It's possible to turn off the ad-hoc rule that a paren |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1206 in column zero is the start of a defun. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1207 'infodock This is Infodock (based on XEmacs). |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1208 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1209 '8-bit and '1-bit are mutually exclusive.") |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1210 |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1211 |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1212 ;;; Some helper constants. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1213 |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1214 ;; If the regexp engine supports POSIX char classes then we can use |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1215 ;; them to handle extended charsets correctly. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1216 (if (memq 'posix-char-classes c-emacs-features) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1217 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1218 (defconst c-alpha "[:alpha:]") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1219 (defconst c-alnum "[:alnum:]") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1220 (defconst c-digit "[:digit:]") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1221 (defconst c-upper "[:upper:]") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1222 (defconst c-lower "[:lower:]")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1223 (defconst c-alpha "a-zA-Z") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1224 (defconst c-alnum "a-zA-Z0-9") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1225 (defconst c-digit "0-9") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1226 (defconst c-upper "A-Z") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1227 (defconst c-lower "a-z")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1228 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1229 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1230 ;;; System for handling language dependent constants. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1231 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1232 ;; This is used to set various language dependent data in a flexible |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1233 ;; way: Language constants can be built from the values of other |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1234 ;; language constants, also those for other languages. They can also |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1235 ;; process the values of other language constants uniformly across all |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1236 ;; the languages. E.g. one language constant can list all the type |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1237 ;; keywords in each language, and another can build a regexp for each |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1238 ;; language from those lists without code duplication. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1239 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1240 ;; Language constants are defined with `c-lang-defconst', and their |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1241 ;; value forms (referred to as source definitions) are evaluated only |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1242 ;; on demand when requested for a particular language with |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1243 ;; `c-lang-const'. It's therefore possible to refer to the values of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1244 ;; constants defined later in the file, or in another file, just as |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1245 ;; long as all the relevant `c-lang-defconst' have been loaded when |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1246 ;; `c-lang-const' is actually evaluated from somewhere else. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1247 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1248 ;; `c-lang-const' forms are also evaluated at compile time and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1249 ;; replaced with the values they produce. Thus there's no overhead |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1250 ;; for this system when compiled code is used - only the values |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1251 ;; actually used in the code are present, and the file(s) containing |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1252 ;; the `c-lang-defconst' forms don't need to be loaded at all then. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1253 ;; There are however safeguards to make sure that they can be loaded |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1254 ;; to get the source definitions for the values if there's a mismatch |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1255 ;; in compiled versions, or if `c-lang-const' is used uncompiled. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1256 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1257 ;; Note that the source definitions in a `c-lang-defconst' form are |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1258 ;; compiled into the .elc file where it stands; there's no need to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1259 ;; load the source file to get it. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1260 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1261 ;; See cc-langs.el for more details about how this system is deployed |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1262 ;; in CC Mode, and how the associated language variable system |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1263 ;; (`c-lang-defvar') works. That file also contains a lot of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1264 ;; examples. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1265 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1266 (defun c-add-language (mode base-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1267 "Declare a new language in the language dependent variable system. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1268 This is intended to be used by modes that inherit CC Mode to add new |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1269 languages. It should be used at the top level before any calls to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1270 `c-lang-defconst'. MODE is the mode name symbol for the new language, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1271 and BASE-MODE is the mode name symbol for the language in CC Mode that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1272 is to be the template for the new mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1273 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1274 The exact effect of BASE-MODE is to make all language constants that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1275 haven't got a setting in the new language fall back to their values in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1276 BASE-MODE. It does not have any effect outside the language constant |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1277 system." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1278 (unless (string-match "\\`\\(.*-\\)mode\\'" (symbol-name mode)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1279 (error "The mode name symbol `%s' must end with \"-mode\"" mode)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1280 (put mode 'c-mode-prefix (match-string 1 (symbol-name mode))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1281 (unless (get base-mode 'c-mode-prefix) |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1282 (error "Unknown base mode `%s'" base-mode)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1283 (put mode 'c-fallback-mode base-mode)) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1284 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1285 (defvar c-lang-constants (make-vector 151 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1286 ;; This obarray is a cache to keep track of the language constants |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1287 ;; defined by `c-lang-defconst' and the evaluated values returned by |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1288 ;; `c-lang-const'. It's mostly used at compile time but it's not |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1289 ;; stored in compiled files. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1290 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1291 ;; The obarray contains all the language constants as symbols. The |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1292 ;; value cells hold the evaluated values as alists where each car is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1293 ;; the mode name symbol and the corresponding cdr is the evaluated |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1294 ;; value in that mode. The property lists hold the source definitions |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1295 ;; and other miscellaneous data. The obarray might also contain |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1296 ;; various other symbols, but those don't have any variable bindings. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1297 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1298 (defvar c-lang-const-expansion nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1299 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1300 (defsubst c-get-current-file () |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1301 ;; Return the base name of the current file. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1302 (let ((file (cond |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1303 (load-in-progress |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1304 ;; Being loaded. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1305 load-file-name) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1306 ((and (boundp 'byte-compile-dest-file) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1307 (stringp byte-compile-dest-file)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1308 ;; Being compiled. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1309 byte-compile-dest-file) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1310 (t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1311 ;; Being evaluated interactively. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1312 (buffer-file-name))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1313 (and file |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1314 (file-name-sans-extension |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1315 (file-name-nondirectory file))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1316 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1317 (defmacro c-lang-defconst-eval-immediately (form) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1318 "Can be used inside a VAL in `c-lang-defconst' to evaluate FORM |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1319 immediately, i.e. at the same time as the `c-lang-defconst' form |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1320 itself is evaluated." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1321 ;; Evaluate at macro expansion time, i.e. in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1322 ;; `cl-macroexpand-all' inside `c-lang-defconst'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1323 (eval form)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1324 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1325 (defmacro c-lang-defconst (name &rest args) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1326 "Set the language specific values of the language constant NAME. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1327 The second argument can be an optional docstring. The rest of the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1328 arguments are one or more repetitions of LANG VAL where LANG specifies |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1329 the language(s) that VAL applies to. LANG is the name of the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1330 language, i.e. the mode name without the \"-mode\" suffix, or a list |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1331 of such language names, or `t' for all languages. VAL is a form to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1332 evaluate to get the value. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1333 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1334 If LANG isn't `t' or one of the core languages in CC Mode, it must |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1335 have been declared with `c-add-language'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1336 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1337 Neither NAME, LANG nor VAL are evaluated directly - they should not be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1338 quoted. `c-lang-defconst-eval-immediately' can however be used inside |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1339 VAL to evaluate parts of it directly. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1340 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1341 When VAL is evaluated for some language, that language is temporarily |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1342 made current so that `c-lang-const' without an explicit language can |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1343 be used inside VAL to refer to the value of a language constant in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1344 same language. That is particularly useful if LANG is `t'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1345 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1346 VAL is not evaluated right away but rather when the value is requested |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1347 with `c-lang-const'. Thus it's possible to use `c-lang-const' inside |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1348 VAL to refer to language constants that haven't been defined yet. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1349 However, if the definition of a language constant is in another file |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1350 then that file must be loaded \(at compile time) before it's safe to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1351 reference the constant. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1352 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1353 The assignments in ARGS are processed in sequence like `setq', so |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1354 \(c-lang-const NAME) may be used inside a VAL to refer to the last |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1355 assigned value to this language constant, or a value that it has |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1356 gotten in another earlier loaded file. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1357 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1358 To work well with repeated loads and interactive reevaluation, only |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1359 one `c-lang-defconst' for each NAME is permitted per file. If there |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1360 already is one it will be completely replaced; the value in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1361 earlier definition will not affect `c-lang-const' on the same |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1362 constant. A file is identified by its base name. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1363 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1364 This macro does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1365 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1366 (let* ((sym (intern (symbol-name name) c-lang-constants)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1367 ;; Make `c-lang-const' expand to a straightforward call to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1368 ;; `c-get-lang-constant' in `cl-macroexpand-all' below. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1369 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1370 ;; (The default behavior, i.e. to expand to a call inside |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1371 ;; `eval-when-compile' should be equivalent, since that macro |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1372 ;; should only expand to its content if it's used inside a |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1373 ;; form that's already evaluated at compile time. It's |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1374 ;; however necessary to use our cover macro |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1375 ;; `cc-eval-when-compile' due to bugs in `eval-when-compile', |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1376 ;; and it expands to a bulkier form that in this case only is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1377 ;; unnecessary garbage that we don't want to store in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1378 ;; language constant source definitions.) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1379 (c-lang-const-expansion 'call) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1380 (c-langs-are-parametric t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1381 bindings |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1382 pre-files) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1383 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1384 (or (symbolp name) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1385 (error "Not a symbol: %s" name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1386 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1387 (when (stringp (car-safe args)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1388 ;; The docstring is hardly used anywhere since there's no normal |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1389 ;; symbol to attach it to. It's primarily for getting the right |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1390 ;; format in the source. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1391 (put sym 'variable-documentation (car args)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1392 (setq args (cdr args))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1393 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1394 (or args |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1395 (error "No assignments in `c-lang-defconst' for %s" name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1396 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1397 ;; Rework ARGS to an association list to make it easier to handle. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1398 ;; It's reversed at the same time to make it easier to implement |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1399 ;; the demand-driven (i.e. reversed) evaluation in `c-lang-const'. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1400 (while args |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1401 (let ((assigned-mode |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1402 (cond ((eq (car args) t) t) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1403 ((symbolp (car args)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1404 (list (intern (concat (symbol-name (car args)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1405 "-mode")))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1406 ((listp (car args)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1407 (mapcar (lambda (lang) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1408 (or (symbolp lang) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1409 (error "Not a list of symbols: %s" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1410 (car args))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1411 (intern (concat (symbol-name lang) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1412 "-mode"))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1413 (car args))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1414 (t (error "Not a symbol or a list of symbols: %s" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1415 (car args))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1416 val) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1417 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1418 (or (cdr args) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1419 (error "No value for %s" (car args))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1420 (setq args (cdr args) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1421 val (car args)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1422 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1423 ;; Emacs has a weird bug where it seems to fail to read |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1424 ;; backquote lists from byte compiled files correctly (,@ |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1425 ;; forms, to be specific), so make sure the bindings in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1426 ;; expansion below doesn't contain any backquote stuff. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1427 ;; (XEmacs handles it correctly and doesn't need this for that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1428 ;; reason, but we also use this expansion handle |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1429 ;; `c-lang-defconst-eval-immediately' and to register |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1430 ;; dependencies on the `c-lang-const's in VAL.) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1431 (setq val (cl-macroexpand-all val)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1432 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1433 (setq bindings (cons (cons assigned-mode val) bindings) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1434 args (cdr args)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1435 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1436 ;; Compile in the other files that have provided source |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1437 ;; definitions for this symbol, to make sure the order in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1438 ;; `source' property is correct even when files are loaded out of |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1439 ;; order. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1440 (setq pre-files (nreverse |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1441 ;; Reverse to get the right load order. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1442 (mapcar 'car (get sym 'source)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1443 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1444 `(eval-and-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1445 (c-define-lang-constant ',name ',bindings |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1446 ,@(and pre-files `(',pre-files)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1447 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1448 (put 'c-lang-defconst 'lisp-indent-function 1) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1449 (eval-after-load "edebug" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1450 '(def-edebug-spec c-lang-defconst |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1451 (&define name [&optional stringp] [&rest sexp def-form]))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1452 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1453 (defun c-define-lang-constant (name bindings &optional pre-files) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1454 ;; Used by `c-lang-defconst'. This function does not do any hidden |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1455 ;; buffer changes. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1456 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1457 (let* ((sym (intern (symbol-name name) c-lang-constants)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1458 (source (get sym 'source)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1459 (file (intern |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1460 (or (c-get-current-file) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1461 (error "`c-lang-defconst' must be used in a file")))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1462 (elem (assq file source))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1463 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1464 ;;(when (cdr-safe elem) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1465 ;; (message "Language constant %s redefined in %S" name file)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1466 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1467 ;; Note that the order in the source alist is relevant. Like how |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1468 ;; `c-lang-defconst' reverses the bindings, this reverses the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1469 ;; order between files so that the last to evaluate comes first. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1470 (unless elem |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1471 (while pre-files |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1472 (unless (assq (car pre-files) source) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1473 (setq source (cons (list (car pre-files)) source))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1474 (setq pre-files (cdr pre-files))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1475 (put sym 'source (cons (setq elem (list file)) source))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1476 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1477 (setcdr elem bindings) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1478 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1479 ;; Bind the symbol as a variable, or clear any earlier evaluated |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1480 ;; value it has. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1481 (set sym nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1482 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1483 ;; Clear the evaluated values that depend on this source. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1484 (let ((agenda (get sym 'dependents)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1485 (visited (make-vector 101 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1486 ptr) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1487 (while agenda |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1488 (setq sym (car agenda) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1489 agenda (cdr agenda)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1490 (intern (symbol-name sym) visited) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1491 (set sym nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1492 (setq ptr (get sym 'dependents)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1493 (while ptr |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1494 (setq sym (car ptr) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1495 ptr (cdr ptr)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1496 (unless (intern-soft (symbol-name sym) visited) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1497 (setq agenda (cons sym agenda)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1498 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1499 name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1500 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1501 (defmacro c-lang-const (name &optional lang) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1502 "Get the mode specific value of the language constant NAME in language LANG. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1503 LANG is the name of the language, i.e. the mode name without the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1504 \"-mode\" suffix. If used inside `c-lang-defconst' or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1505 `c-lang-defvar', LANG may be left out to refer to the current |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1506 language. NAME and LANG are not evaluated so they should not be |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1507 quoted. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1508 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1509 This macro does not do any hidden buffer changes." |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1510 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1511 (or (symbolp name) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1512 (error "Not a symbol: %s" name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1513 (or (symbolp lang) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1514 (error "Not a symbol: %s" lang)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1515 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1516 (let ((sym (intern (symbol-name name) c-lang-constants)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1517 mode source-files args) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1518 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1519 (if lang |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1520 (progn |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1521 (setq mode (intern (concat (symbol-name lang) "-mode"))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1522 (unless (get mode 'c-mode-prefix) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1523 (error |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1524 "Unknown language %S since it got no `c-mode-prefix' property" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1525 (symbol-name lang)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1526 (if c-buffer-is-cc-mode |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1527 (setq lang c-buffer-is-cc-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1528 (or c-langs-are-parametric |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1529 (error |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1530 "`c-lang-const' requires a literal language in this context")))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1531 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1532 (if (eq c-lang-const-expansion 'immediate) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1533 ;; No need to find out the source file(s) when we evaluate |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1534 ;; immediately since all the info is already there in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1535 ;; `source' property. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1536 `',(c-get-lang-constant name nil mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1537 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1538 (let ((file (c-get-current-file))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1539 (if file (setq file (intern file))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1540 ;; Get the source file(s) that must be loaded to get the value |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1541 ;; of the constant. If the symbol isn't defined yet we assume |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1542 ;; that its definition will come later in this file, and thus |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1543 ;; are no file dependencies needed. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1544 (setq source-files (nreverse |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1545 ;; Reverse to get the right load order. |
51887
a39d64d1eb50
(c-make-keywords-re): Don't use delete-duplicates.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
1546 (apply 'nconc |
a39d64d1eb50
(c-make-keywords-re): Don't use delete-duplicates.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
1547 (mapcar (lambda (elem) |
a39d64d1eb50
(c-make-keywords-re): Don't use delete-duplicates.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
1548 (if (eq file (car elem)) |
a39d64d1eb50
(c-make-keywords-re): Don't use delete-duplicates.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
1549 nil ; Exclude our own file. |
a39d64d1eb50
(c-make-keywords-re): Don't use delete-duplicates.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
1550 (list (car elem)))) |
a39d64d1eb50
(c-make-keywords-re): Don't use delete-duplicates.
Richard M. Stallman <rms@gnu.org>
parents:
51829
diff
changeset
|
1551 (get sym 'source)))))) |
51714
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1552 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1553 ;; Spend some effort to make a compact call to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1554 ;; `c-get-lang-constant' since it will be compiled in. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1555 (setq args (and mode `(',mode))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1556 (if (or source-files args) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1557 (setq args (cons (and source-files `',source-files) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1558 args))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1559 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1560 (if (or (eq c-lang-const-expansion 'call) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1561 load-in-progress |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1562 (not (boundp 'byte-compile-dest-file)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1563 (not (stringp byte-compile-dest-file))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1564 ;; Either a straight call is requested in the context, or |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1565 ;; we're not being byte compiled so the compile time stuff |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1566 ;; below is unnecessary. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1567 `(c-get-lang-constant ',name ,@args) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1568 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1569 ;; Being compiled. If the loading and compiling version is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1570 ;; the same we use a value that is evaluated at compile time, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1571 ;; otherwise it's evaluated at runtime. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1572 `(if (eq c-version-sym ',c-version-sym) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1573 (cc-eval-when-compile |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1574 (c-get-lang-constant ',name ,@args)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1575 (c-get-lang-constant ',name ,@args)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1576 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1577 (defvar c-lang-constants-under-evaluation nil) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1578 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1579 (defun c-get-lang-constant (name &optional source-files mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1580 ;; Used by `c-lang-const'. This function does not do any hidden |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1581 ;; buffer changes. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1582 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1583 (or mode |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1584 (setq mode c-buffer-is-cc-mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1585 (error "No current language")) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1586 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1587 (let* ((sym (intern (symbol-name name) c-lang-constants)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1588 (source (get sym 'source)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1589 elem |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1590 (eval-in-sym (and c-lang-constants-under-evaluation |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1591 (caar c-lang-constants-under-evaluation)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1592 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1593 ;; Record the dependencies between this symbol and the one we're |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1594 ;; being evaluated in. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1595 (when eval-in-sym |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1596 (or (memq eval-in-sym (get sym 'dependents)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1597 (put sym 'dependents (cons eval-in-sym (get sym 'dependents))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1598 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1599 ;; Make sure the source files have entries on the `source' |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1600 ;; property so that loading will take place when necessary. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1601 (while source-files |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1602 (unless (assq (car source-files) source) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1603 (put sym 'source |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1604 (setq source (cons (list (car source-files)) source))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1605 ;; Might pull in more definitions which affect the value. The |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1606 ;; clearing of dependent values etc is done when the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1607 ;; definition is encountered during the load; this is just to |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1608 ;; jump past the check for a cached value below. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1609 (set sym nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1610 (setq source-files (cdr source-files))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1611 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1612 (if (and (boundp sym) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1613 (setq elem (assq mode (symbol-value sym)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1614 (cdr elem) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1615 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1616 ;; Check if an evaluation of this symbol is already underway. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1617 ;; In that case we just continue with the "assignment" before |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1618 ;; the one currently being evaluated, thereby creating the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1619 ;; illusion if a `setq'-like sequence of assignments. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1620 (let* ((c-buffer-is-cc-mode mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1621 (source-pos |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1622 (or (assq sym c-lang-constants-under-evaluation) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1623 (cons sym (vector source nil)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1624 ;; Append `c-lang-constants-under-evaluation' even if an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1625 ;; earlier entry is found. It's only necessary to get |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1626 ;; the recording of dependencies above correct. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1627 (c-lang-constants-under-evaluation |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1628 (cons source-pos c-lang-constants-under-evaluation)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1629 (fallback (get mode 'c-fallback-mode)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1630 value |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1631 ;; Make sure the recursion limits aren't very low |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1632 ;; since the `c-lang-const' dependencies can go deep. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1633 (max-specpdl-size (max max-specpdl-size 3000)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1634 (max-lisp-eval-depth (max max-lisp-eval-depth 1000))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1635 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1636 (if (if fallback |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1637 (let ((backup-source-pos (copy-sequence (cdr source-pos)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1638 (and |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1639 ;; First try the original mode but don't accept an |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1640 ;; entry matching all languages since the fallback |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1641 ;; mode might have an explicit entry before that. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1642 (eq (setq value (c-find-assignment-for-mode |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1643 (cdr source-pos) mode nil name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1644 c-lang-constants) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1645 ;; Try again with the fallback mode from the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1646 ;; original position. Note that |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1647 ;; `c-buffer-is-cc-mode' still is the real mode if |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1648 ;; language parameterization takes place. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1649 (eq (setq value (c-find-assignment-for-mode |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1650 (setcdr source-pos backup-source-pos) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1651 fallback t name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1652 c-lang-constants))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1653 ;; A simple lookup with no fallback mode. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1654 (eq (setq value (c-find-assignment-for-mode |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1655 (cdr source-pos) mode t name)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1656 c-lang-constants)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1657 (error |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1658 "`%s' got no (prior) value in %s (might be a cyclic reference)" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1659 name mode)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1660 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1661 (condition-case err |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1662 (setq value (eval value)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1663 (error |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1664 ;; Print a message to aid in locating the error. We don't |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1665 ;; print the error itself since that will be done later by |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1666 ;; some caller higher up. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1667 (message "Eval error in the `c-lang-defconst' for `%s' in %s:" |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1668 sym mode) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1669 (makunbound sym) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1670 (signal (car err) (cdr err)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1671 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1672 (set sym (cons (cons mode value) (symbol-value sym))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1673 value)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1674 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1675 (defun c-find-assignment-for-mode (source-pos mode match-any-lang name) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1676 ;; Find the first assignment entry that applies to MODE at or after |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1677 ;; SOURCE-POS. If MATCH-ANY-LANG is non-nil, entries with `t' as |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1678 ;; the language list are considered to match, otherwise they don't. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1679 ;; On return SOURCE-POS is updated to point to the next assignment |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1680 ;; after the returned one. If no assignment is found, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1681 ;; `c-lang-constants' is returned as a magic value. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1682 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1683 ;; SOURCE-POS is a vector that points out a specific assignment in |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1684 ;; the double alist that's used in the `source' property. The first |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1685 ;; element is the position in the top alist which is indexed with |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1686 ;; the source files, and the second element is the position in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1687 ;; nested bindings alist. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1688 ;; |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1689 ;; NAME is only used for error messages. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1690 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1691 (catch 'found |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1692 (let ((file-entry (elt source-pos 0)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1693 (assignment-entry (elt source-pos 1)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1694 assignment) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1695 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1696 (while (if assignment-entry |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1697 t |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1698 ;; Handled the last assignment from one file, begin on the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1699 ;; next. Due to the check in `c-lang-defconst', we know |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1700 ;; there's at least one. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1701 (when file-entry |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1702 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1703 (unless (aset source-pos 1 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1704 (setq assignment-entry (cdar file-entry))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1705 ;; The file containing the source definitions has not |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1706 ;; been loaded. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1707 (let ((file (symbol-name (caar file-entry))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1708 (c-lang-constants-under-evaluation nil)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1709 ;;(message (concat "Loading %s to get the source " |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1710 ;; "value for language constant %s") |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1711 ;; file name) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1712 (load file)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1713 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1714 (unless (setq assignment-entry (cdar file-entry)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1715 ;; The load didn't fill in the source for the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1716 ;; constant as expected. The situation is |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1717 ;; probably that a derived mode was written for |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1718 ;; and compiled with another version of CC Mode, |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1719 ;; and the requested constant isn't in the |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1720 ;; currently loaded one. Put in a dummy |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1721 ;; assignment that matches no language. |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1722 (setcdr (car file-entry) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1723 (setq assignment-entry (list (list nil)))))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1724 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1725 (aset source-pos 0 (setq file-entry (cdr file-entry))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1726 t)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1727 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1728 (setq assignment (car assignment-entry)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1729 (aset source-pos 1 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1730 (setq assignment-entry (cdr assignment-entry))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1731 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1732 (when (if (listp (car assignment)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1733 (memq mode (car assignment)) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1734 match-any-lang) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1735 (throw 'found (cdr assignment)))) |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1736 |
bc91cbf50c24
Updated CC Mode to version 5.30.
Martin Stjernholm <mast@lysator.liu.se>
parents:
49598
diff
changeset
|
1737 c-lang-constants))) |
24282 | 1738 |
56646
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1739 (defun c-lang-major-mode-is (mode) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1740 ;; `c-major-mode-is' expands to a call to this function inside |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1741 ;; `c-lang-defconst'. Here we also match the mode(s) against any |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1742 ;; fallback modes for the one in `c-buffer-is-cc-mode', so that |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1743 ;; e.g. (c-major-mode-is 'c++-mode) is true in a derived language |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1744 ;; that has c++-mode as base mode. |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1745 (unless (listp mode) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1746 (setq mode (list mode))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1747 (let (match (buf-mode c-buffer-is-cc-mode)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1748 (while (if (memq buf-mode mode) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1749 (progn |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1750 (setq match t) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1751 nil) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1752 (setq buf-mode (get buf-mode 'c-fallback-mode)))) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1753 match)) |
b7446b6f097d
Updated CC Mode to 5.30.9.
Martin Stjernholm <mast@lysator.liu.se>
parents:
53610
diff
changeset
|
1754 |
18720 | 1755 |
36920 | 1756 (cc-provide 'cc-defs) |
38422
7a94f1c588c4
Some fixes to follow coding conventions.
Pavel Janík <Pavel@Janik.cz>
parents:
36920
diff
changeset
|
1757 |
52401 | 1758 ;;; arch-tag: 3bb2629d-dd84-4ff0-ad39-584be0fe3cda |
18720 | 1759 ;;; cc-defs.el ends here |